Exam 10: Inheritance and Polymorphism

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

An abstract method ____.

(Multiple Choice)
4.9/5
(37)

In dynamic binding, the method that gets executed is determined at compile time, not at execution time.

(True/False)
4.7/5
(43)

An abstract class ____.

(Multiple Choice)
4.8/5
(38)

  -Based on the diagram in the accompanying figure, the method setDimension in the class Box ____ the method setDimension in the class Rectangle. -Based on the diagram in the accompanying figure, the method setDimension in the class Box ____ the method setDimension in the class Rectangle.

(Multiple Choice)
4.8/5
(32)

An interface is a class that contains only abstract methods and/or named constants.

(True/False)
4.9/5
(42)

Redefining a method of a superclass is also known as overloading a method.

(True/False)
4.7/5
(33)

Suppose that the class Mystery is derived from the class Secret. Consider the following statements. Secret secRef = new Secret(); Mystery mysRef = new Mystery(); Which of the following statements is legal in Java? (i) secRef = mysRef; (ii) mysRef = secRef;

(Multiple Choice)
4.8/5
(43)

Java uses late binding for methods that are private but not for methods that are marked final.

(True/False)
4.9/5
(41)

Which of the following statements about the reference super is true?

(Multiple Choice)
4.8/5
(41)

Consider the following class definitions. public class BClass {private int x; public void set(int a) { x = a; } public void print(){ }} public class DClass extends BClass {private int y; public void set(int a, int b) {//Postcondition: x = a; y = b;} public void print(){ }} Which of the following is the correct definition of the method set of the class DClass? (i) public void set(int a, int b) {super.set(a); y = b;} (ii) public void set(int a, int b) {x = a; y = b;}

(Multiple Choice)
4.9/5
(38)

Inheritance implies an "is-a" relationship.

(True/False)
4.9/5
(30)

Inheritance is an example of what type of relationship?

(Multiple Choice)
4.8/5
(45)

Consider the following class definitions. public class BClass {private int x; private double y; public void print() { }} public class DClass extends BClass {private int a; private int b; public void print() { }} Suppose that you have the following statement. DClass dObject = new DClass(); How many instance variables does dObject have?

(Multiple Choice)
4.9/5
(43)

Which operator is used to determine if an object is of a particular class type?

(Multiple Choice)
4.8/5
(35)

Composition is also called ____.

(Multiple Choice)
4.8/5
(38)

Suppose there are three classes named Shape, Circle, and Square. What is the most likely relationship between them?

(Multiple Choice)
4.9/5
(36)

A polymorphic reference variable can refer to either an object of its own class or an object of the subclasses inherited from its class.

(True/False)
4.8/5
(43)

  -Based on the diagram in the accompanying figure, the method area in the class Box ____ the method area in the class Rectangle. -Based on the diagram in the accompanying figure, the method area in the class Box ____ the method area in the class Rectangle.

(Multiple Choice)
4.7/5
(33)

A subclass cannot directly access public members of a superclass.

(True/False)
4.9/5
(37)

In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass.

(True/False)
4.8/5
(25)
Showing 21 - 40 of 50
close modal

Filters

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