Exam 9: Inheritance and Interfaces

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

Which of the following statements about inheritance is correct?

(Multiple Choice)
4.8/5
(44)

Consider the following code snippet: Vehicle aVehicle = new Auto(); AVehicle.moveForward(200); If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct?

(Multiple Choice)
4.7/5
(36)

Consider the following code snippet: Public class Inventory implements Measurable { Private int onHandCount; ) . . Double getMeasure(); { Return onHandCount; } } Assume that getMeasure() is a method in the interface Measurable. The compiler complains that the getMeasure method has a weaker access level than the Measurable interface. Why?

(Multiple Choice)
4.8/5
(36)

Consider the following code snippet: Auto consumerAuto = new Auto(4, "gasoline"); String s = consumerAuto.toString(); Assume that the Auto class has not implemented its own toString() method. What value will s contain when this code is executed?

(Multiple Choice)
4.8/5
(37)

Consider the following code snippet: Public class Vessel { ) . . Public void setVesselClass(double numberAxles) { ) . . } } Public class Speedboat extends Vessel { ) . . Public void setVesselClass(double numberAxles) { ) . . } } Which of the following statements is correct?

(Multiple Choice)
4.7/5
(44)

Consider the following code snippet: Public class Motorcycle extends Vehicle { ) . . Public Motorcycle(int numberAxles) { Super(numberAxles); //line #1 } } If the line marked "//line #1" was missing, which of these statements would be correct?

(Multiple Choice)
4.8/5
(36)

Consider the following code snippet: Public class Vehicle { ) . . Public void setVehicleClass(double numberAxles) { ) . . } } Public class Motorcycle extends Vehicle { ) . . Public void setModelName(String model) { ) . . } Public void setVehicleClass(double numberAxles) { ) . . } } Which of the following statements is NOT correct?

(Multiple Choice)
4.9/5
(38)

Which of the following statements about classes is true?

(Multiple Choice)
4.9/5
(39)

Consider the following code snippet: Double salary = 45000.00; String sal = "Current salary is " + salary; Which of the following statements is correct?

(Multiple Choice)
4.9/5
(46)

Which of the following is true regarding subclasses?

(Multiple Choice)
5.0/5
(39)

Which of the following statements about a Java interface is NOT true?

(Multiple Choice)
4.9/5
(42)

All ____ methods must be implemented when using an interface.

(Multiple Choice)
4.8/5
(34)

Consider the following code snippet: Public class Auto extends Vehicle { ) . . Public Auto(int numberAxles) { Super(numberAxles); } } What does this code do?

(Multiple Choice)
4.9/5
(36)

Which of the following statements about comparing objects is correct?

(Multiple Choice)
4.8/5
(39)

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
(36)

Consider the following code snippet: Public class Motorcycle extends Vehicle { Private String model; ) . . Public Motorcycle(int numberAxles, String modelName) { Super(numberAxles); Model = modelName; } } What does this code do?

(Multiple Choice)
4.9/5
(40)

Which of the following statements about superclasses and subclasses is true?

(Multiple Choice)
4.9/5
(33)

Consider the following code snippet of a function object Public interface Measurer { Double measure(______ anObject); } Complete this code to allow the interface to handle all classes?

(Multiple Choice)
4.8/5
(38)

Which of the following indicates that a class named ClassA class is a superclass of the ClassB class?

(Multiple Choice)
4.8/5
(42)

Consider the following code snippet: Public abstract class Machine { Public abstract void setRPMs(); ) . . } You wish to create a subclass named PolisherMachine. Which of the following is the correct way to declare this subclass?

(Multiple Choice)
4.7/5
(31)
Showing 41 - 60 of 99
close modal

Filters

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