Exam 9: Inheritance

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

Consider the following code snippet: Consider the following code snippet:   Assume that 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.What determines which class's moveForward method is to be executed? Assume that 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.What determines which class's moveForward method is to be executed?

Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
Verified

A

Consider the following code snippet: Consider the following code snippet:   What does this code do? What does this code do?

Free
(Multiple Choice)
4.9/5
(36)
Correct Answer:
Verified

D

With a few exceptions, what access should instance variables of classes always have?

Free
(Multiple Choice)
4.9/5
(42)
Correct Answer:
Verified

B

Consider the following code snippet: Consider the following code snippet:   Assume that the Employee class has not implemented its own toString() method.What value will s contain when this code is executed? 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.9/5
(46)

Which of the following statements about inheritance is correct?

(Multiple Choice)
4.7/5
(33)

Consider the classes shown below: Consider the classes shown below:

(Multiple Choice)
4.8/5
(37)

In Java, if you define two methods that have the same but different parameter types, the compiler will not complain. Why not?

(Multiple Choice)
4.9/5
(37)

Suppose the class Message is partially defined as shown below: Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior? A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below: Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior? Which ExcitedMessage constructor will give this behavior?

(Multiple Choice)
4.8/5
(29)

Consider the following code snippet that appears in a subclass: Consider the following code snippet that appears in a subclass:   Which of the following statements is true? Which of the following statements is true?

(Multiple Choice)
4.8/5
(37)

Consider the following code snippet: Consider the following code snippet:   If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct? If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct?

(Multiple Choice)
4.7/5
(32)

Suppose the class Value is partially defined below Suppose the class Value is partially defined below   A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method? A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method?

(Multiple Choice)
4.9/5
(37)

What is a class called that represents the most general entity in an inheritance hierarchy?

(Multiple Choice)
4.8/5
(28)

Which reserved word must be used to call a method of a superclass?

(Multiple Choice)
4.8/5
(27)

Consider the classes shown below: Consider the classes shown below:

(Multiple Choice)
4.9/5
(37)

Consider the following code snippet: Consider the following code snippet:   What does this code do? What does this code do?

(Multiple Choice)
4.9/5
(34)

Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? Which of the following statements is correct?

(Multiple Choice)
4.8/5
(42)

Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy?  Which represent valid class headers that would be found in this hierarchy?

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

Consider the Counter class below. Consider the Counter class below.

(Multiple Choice)
4.9/5
(40)

Consider the following class hierarchy: Consider the following class hierarchy:   When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy? When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy?

(Multiple Choice)
4.8/5
(33)
Showing 1 - 20 of 99
close modal

Filters

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