Solved

Consider the Following Class Hierarchy: Public Class Vehicle

Question 72

Multiple Choice

Consider the following class hierarchy: public class Vehicle
{
Private String type;
Public Vehicle(String type)
{
This.type = type;
}
Public String getType()
{
Return type;
}
}
Public class LandVehicle extends Vehicle
{
Public LandVehicle(String type)
{
) . .
}
}
Public class Auto extends LandVehicle
{
Public Auto(String type)
{
) . .
}
}
Which of the following code fragments is NOT valid in Java?


A) Vehicle myAuto = new Auto("sedan") ;
B) LandVehicle myAuto = new Auto("sedan") ;
C) Auto myAuto = new Auto("sedan") ;
D) LandVehicle myAuto = new Vehicle("sedan") ;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions