Consider the following classes: public class Vehicle {...} public class Car extends Vehicle {...} public class SUV extends Car {
...} Self-Check Problems 617 Which of the following are legal statements? a. Vehicle v = new Car(); b. Vehicle v = new SUV(); c. Car c = new SUV(); d. SUV s = new SUV(); e. SUV s = new Car(); f. Car c = new Vehicle();
The options a, b, c, d are correct and legal statements because the syntax is correct, they follow the inheritance principles and therefore can be used for type cast.
The options e, f are incorrect and illegal statements because they do not follow the inheritance principles and therefore can not be used for type cast.