Exam 9: Inheritance and Interfaces

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? 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)

To create a subclass, use the ____ keyword.

(Multiple Choice)
4.8/5
(34)

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)

Which of the following is true regarding inheritance?

(Multiple Choice)
4.7/5
(35)

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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)