Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I don't understand: what I think is that since SUV extends Car extends Vehicle, SUV should have the suv, car and vehicle constructors, Car should

image text in transcribedimage text in transcribedI don't understand: what I think is that since SUV extends Car extends Vehicle, SUV should have the suv, car and vehicle constructors, Car should have the Car and vehicle constructors, and Vehicle should just have the vehicle constructor. So how come statements like the first one, which are calling a constructor in a subclass from a superclass, are legal? Shouldn't all the answers be flipped (except d)? class_name object_name = new class_name(); public class Vehicle {} public class Car extends Vehic le {} public class SUV extends Car {} 4. The following statements are marked as legal or illegal: a. Vehicle v= new Car();// legal b. Vehicle v= new SUV();// legal c. Car c = new SUV(); // legal d. SUV s= new SUV(); // legal e. SUV s= new Car(); // illegal f. Car c= new Vehicle( );// illegal

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago