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
Q36: If a subclass defines the same method
Q37: Consider the following code snippet:
Public class Vessel
{
Private
Q38: Consider the following class hierarchy:
Public class Vehicle
{
Private
Q39: Consider the following code snippet:
Public class Employee
{
)
Q40: Consider the following code snippet:
Public void deposit(double
Q42: Consider the following code snippet:
Public abstract class
Q43: Consider the following code snippet:
Public class Motorcycle
Q46: Consider the following code snippet:
Public class Motorcycle
Q72: Consider the following code snippet: Employee anEmployee
Q77: Consider the following code snippet: Vehicle aVehicle
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