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:
Verified
Q63: Which of the following statements about abstract
Q76: Consider the Counter class below. public class
Q77: Consider the following code snippet: Vehicle aVehicle
Q78: Consider the following code snippet: public abstract
Q80: Which of the following statements about classes
Q81: Consider the following code snippet:
Int numAxles =
Q82: Consider the following code snippet of a
Q83: Consider the following code snippet:
Int vacationDays =
Q84: Consider the following code snippet: double salary
Q85: With a few exceptions, instance variables of
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents