Ask Question
7 June, 21:01

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 ();

+4
Answers (1)
  1. 7 June, 22:33
    0
    Legal statements:

    SUV s = new SUV ();

    Car c = new SUV ();

    Vehicle v = new SUV ();

    Vehicle v1 = new Car ();

    illegal statements:

    SUV s1 = new Car ();

    Car c1 = new Vehicle ();

    Explanation:

    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Consider the following classes: public class Vehicle { ... } public class Car extends Vehicle { ... } public class SUV extends Car { ... } ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers