logo

Crowdly

class Vehicle {  void start() { System.out.println("Vehicle starting..."); } } ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

class Vehicle { 

void start() { System.out.println("Vehicle starting..."); }

}

class Car extends Vehicle { 

void start() { System.out.println("Car starting..."); }

}

class Bike extends Vehicle { }

class SportsCar extends Car { }

public class CastingTest {

    public static void main(String[] args) {

        Vehicle v1 = new Car();

        Vehicle v2 = new Bike();

        Car c1 = new Car();

        Bike b1 = new Bike();

        Vehicle v3 = new SportsCar();

        SportsCar sc1 = new SportsCar();

    }

}

Consider the code above to answer the following questions. 

What is the result of each of the following method calls?

  1. Car c2 = (Car) v1;

     //Complete the code

  2. Car c3 = (Car) v2;

     //Complete the code

  3. Vehicle v4 = c1;

     //Complete the code

  4. Bike b3 = (Bike) c1;

     //Complete the code

  5. Vehicle v5 = (Vehicle) b1;

     //Complete the code

  6. c1 = (Car) v3;

     //Complete the code

  7. SportsCar sc2 = (SportsCar) v3;

     //Complete the code

  8. SportsCar sc3 = (SportsCar) v1;

     //Complete the code

  9. SportsCar sc1 = (Car) c1;

     //Complete the code

More questions like this

Want instant access to all verified answers on learn2025.ukzn.ac.za?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!