Exam 9: Inheritance and Interfaces
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
Consider the following code snippet:
Public class Motorcycle extends Vehicle
{
) . .
Public Motorcycle(int numberAxles)
{
Super(numberAxles);
}
}
What does this code do?
(Multiple Choice)
4.8/5
(34)
Consider the following inheritance hierarchy diagram:
Which of the following statements is correct?

(Multiple Choice)
4.9/5
(40)
Consider the following code snippet:
If (anObject instanceof Auto)
{
Auto anAuto = (Auto) anObject;
) . .
}
What does this code do?
(Multiple Choice)
4.9/5
(45)
Which of the following indicates that a class named Class1 is a subclass of a class named Class2?
(Multiple Choice)
4.9/5
(41)
Consider the following code snippet:
Public class Motorcycle extends Vehicle
{
) . .
Public Motorcycle(int numberAxles)
{
Super.numberAxles;
}
}
What does this code do?
(Multiple Choice)
4.8/5
(34)
Consider the following code snippet:
Public class Vehicle
{
Private String manufacturer;
) . .
Public void setVehicleClass(double numberAxles)
{
) . .
}
}
If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct?
(Multiple Choice)
4.9/5
(35)
To define a class that fulfills the requirements of an interface, the class header should include which of the following?
(Multiple Choice)
4.9/5
(37)
What must a subclass do to modify a private superclass instance variable?
(Multiple Choice)
4.7/5
(34)
If a subclass contains a method with the same name as a method in its superclass, but with different parameter types, the subclass method is said to ____ the method of the superclass.
(Multiple Choice)
4.7/5
(33)
The ____ reserved word in a class definition ensures that subclasses cannot be created from this class.
(Multiple Choice)
4.8/5
(34)
A class that represents the most general entity in an inheritance hierarchy is called a/an ____.
(Multiple Choice)
4.9/5
(48)
Insert the missing code in the following code fragment. This fragment is intended to call the Vehicle class's method.
Public class Vehicle
{
) . .
Public void setVehicleClass(double numberAxles)
{
) . .
}
}
Public class Motorcycle extends Vehicle
{
) . .
Public Motorcycle()
{
_______________;
}
}
(Multiple Choice)
4.8/5
(29)
Consider the following code snippet:
Employee anEmployee = new Programmer();
AnEmployee.increaseSalary(2500);
If the Programmer class inherits from the Employee class, and both classes have an implementation of the increaseSalary method with the same set of parameters and the same return type, which statement is correct?
(Multiple Choice)
4.7/5
(35)
Consider the following class hierarchy:
Public class Vehicle
{
Private String type;
Public Vehicle(String type)
{
This.type = type;
}
Public String displayInfo()
{
Return type;
}
}
Public class LandVehicle extends Vehicle
{
Public LandVehicle(String type)
{
Super(type);
}
}
Public class Auto extends LandVehicle
{
Public Auto(String type)
{
Super(type);
}
}
You have written a program to use these classes, as shown in the following code snippet:
Public class VehicleTester
{
Public static void main(String[] args)
{
Auto myAuto = new Auto("sedan");
System.out.println("MyAuto type = " + ______);
}
}
Complete the code in this program snippet to correctly display the auto's type.
(Multiple Choice)
4.7/5
(28)
Which reserved word must be used to call a method of a superclass?
(Multiple Choice)
4.8/5
(28)
To test whether an object belongs to a particular type, use ___.
(Multiple Choice)
4.9/5
(45)
Consider the following code snippet:
Public class Employee
{
) . .
Public void setEmployeeDept(String deptNum)
{
) . .
}
}
Public class Programmer extends Employee
{
) . .
Public void setEmployeeDept(int deptNum)
{
) . .
}
}
Which of the following statements is correct?
(Multiple Choice)
4.8/5
(36)
Showing 81 - 99 of 99
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)