Exam 9: Inheritance and Interfaces

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

Consider the following code snippet: Public class Employee { ) . . Public void setDepartment(String deptName) { ) . . } } Public class Programmer extends Employee { ) . . Public void setProjectName(String projName) { ) . . } Public void setDepartment(String deptName) { ) . . } } Which of the following statements is NOT correct?

(Multiple Choice)
4.8/5
(35)

To override a superclass method in a subclass, the subclass method ____.

(Multiple Choice)
4.8/5
(43)

Consider the following code snippet that appears in a subclass: Public void deposit(double amount) { TransactionCount ++; Deposit(amount); } Which of the following statements is true?

(Multiple Choice)
4.9/5
(35)

If a class has an abstract method, which of the following statements is NOT true?

(Multiple Choice)
4.7/5
(46)

Consider the following code snippet: Public class Vehicle { ) . . Public void setVehicleClass(double numberAxles) { ) . . } } Public class Auto extends Vehicle { ) . . Public void setVehicleClass(int numberAxles) { ) . . } } Which of the following statements is correct?

(Multiple Choice)
4.7/5
(33)

Which of the following can potentially be changed when implementing an interface?

(Multiple Choice)
4.8/5
(42)

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

(Multiple Choice)
4.8/5
(35)

Consider the following code snippet: Employee anEmployee = new Programmer(); AnEmployee.increaseSalary(2500); Assume that 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 class's increaseSalary method is to be executed is determined by ____.

(Multiple Choice)
4.9/5
(41)

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

(Multiple Choice)
4.8/5
(37)

You are creating a Motorcycle class that is supposed to be a subclass of the Vehicle class. Which of the following class declaration statements will accomplish this?

(Multiple Choice)
4.9/5
(30)

A class that cannot be instantiated is called a/an ____.

(Multiple Choice)
4.9/5
(36)

Consider the following code snippet: Public interface Sizable { Int LARGE_CHANGE = 100; Int SMALL_CHANGE = 20; Void changeSize(); } Which of the following statements is true?

(Multiple Choice)
4.9/5
(38)

Consider the following code snippet: Public class Vessel { Private String manufacturer; ) . . Public void setVesselClass(double engineRPM) { ) . . } } If a Speedboat class is created as a subclass of the Vessel class, which of the following statements is correct?

(Multiple Choice)
4.8/5
(35)

Consider the following code snippet: Public class Coin { Private String name; ) . . Public boolean equals(Object otherCoin) { Return name.equals(otherCoin.name); } ) . . } What is wrong with this code?

(Multiple Choice)
4.8/5
(38)

Insert the missing code in the following code fragment. This fragment is intended to call the Vessel class's method. Public class Vessel { ) . . Public void set VesselClass(double vesselLength) { ) . . } } Public class SpeedBoat extends Vessel { ) . . Public SpeedBoat() { _______________; } }

(Multiple Choice)
4.9/5
(38)

Which of the following could be used in place of an interface to handle operations on different classes?

(Multiple Choice)
4.8/5
(37)

Which of the following statements about an interface is true?

(Multiple Choice)
4.9/5
(34)

Consider the following code snippet: Public interface Sizable { Int LARGE_CHANGE = 100; Void changeSize(); } Which of the following indicates how to use the constant LARGE_CHANGE in your program?

(Multiple Choice)
4.7/5
(38)

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) { ) . . } } Public class Auto extends LandVehicle { Public Auto(String type) { ) . . } Public String displayAutoType() { Return _____; } } Complete the code in the Auto class method named displayAutoType to return the type data.

(Multiple Choice)
4.9/5
(30)

The ____ reserved word in a method definition ensures that subclasses cannot override this method.

(Multiple Choice)
4.7/5
(39)
Showing 61 - 80 of 99
close modal

Filters

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