Exam 9: Inheritance

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

Consider the following code snippet: Employee anEmployee = new Programmer(); String emp = anEmployee.toString(); Assume that the Programmer class inherits from the Employee class, and neither class has an implementation of the toString() method. Which of the following statements is correct?

(Multiple Choice)
4.9/5
(32)

Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the superclass of the class TelevisionShow? What is the superclass of the class TelevisionShow?

(Multiple Choice)
4.9/5
(43)

Consider the classes shown below: public class Parent { Private int value = 100; Public int getValue() { Return value; } } Public class Child extends Parent { Private int value; Public Child(int number) { Value = number; } } What is the output of the following lines of code? Child kid = new Child(-14); Parent kid2 = new Child(21); System.out.println(kid.getValue() + " " + kid2.getValue());

(Multiple Choice)
4.8/5
(36)

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.9/5
(42)

Consider the following code snippet: public void deposit(double amount) { TransactionCount ++; Super.deposit(amount); } Which of the following statements is true?

(Multiple Choice)
4.9/5
(28)

If a subclass defines the same method name and the same parameter types for a method that appears in its superclass, ____.

(Multiple Choice)
4.8/5
(41)

Consider the following code snippet: If(anObject instanceof Auto) { Auto anAuto = (Auto) anObject; ) . . } What does this code do?

(Multiple Choice)
4.9/5
(36)

Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the superclass of the class ScriptedShow? What is the superclass of the class ScriptedShow?

(Multiple Choice)
4.8/5
(31)

Which of the following statements about classes is true?

(Multiple Choice)
4.8/5
(41)

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

(Multiple Choice)
4.8/5
(33)

Which of the following statements about classes is true?

(Multiple Choice)
4.8/5
(35)

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.9/5
(34)

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.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.7/5
(39)

Consider the following code snippet: Vehicle aVehicle = new Auto(4,"gasoline"); String s = aVehicle.toString(); Assume that the Auto class inherits from the Vehicle class, and neither class has an implementation of the toString() method. Which of the following statements is correct?

(Multiple Choice)
4.9/5
(37)

Consider the following code snippet: Int vacationDays = 10; String output = "Number of earned vacation days is " + vacationDays; Which of the following statements is correct?

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.8/5
(36)

Which of the following statements about inheritance is correct?

(Multiple Choice)
4.8/5
(31)

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

(Multiple Choice)
4.8/5
(43)

To create a subclass, use the ____ keyword.

(Multiple Choice)
4.9/5
(35)
Showing 81 - 100 of 101
close modal

Filters

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