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:

Verified
Correct Answer:
Verified
Q28: You are creating a class inheritance hierarchy
Q67: Consider the following code snippet: Employee anEmployee
Q68: Consider the classes shown below: public class
Q69: Consider the classes shown below: public class
Q71: You are creating a Motorcycle class which
Q73: Consider the following code snippet: public class
Q74: Consider the following code snippet: public class
Q75: Consider the following class hierarchy: public class
Q76: Consider the Counter class below. public class
Q77: With a few exceptions, instance variables of