Exam 10: Inheritance and Polymorphism

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

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

(Multiple Choice)
4.9/5
(42)

To determine whether a reference variable that points to an object is of a particular class type, Java provides the operator instanceof.

(True/False)
5.0/5
(34)

The superclass inherits all its properties from the subclass.

(True/False)
4.9/5
(42)

Suppose a class Car and its subclass Honda both have a method called speed as part of the class definition. rentalH refers to an object of the type Honda and the following statements are found in the code:rentalH.cost(); Super.speed();In the scenario described in the accompanying figure, what will the first statement do?

(Multiple Choice)
4.9/5
(39)

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)
5.0/5
(43)

Suppose that the class Mystery is derived from the class Secret. The following statements are legal in Java.Secret secRef; Mystery mysRef = new Mystery(); secRef = mysRef;

(True/False)
4.8/5
(30)

A subclass can directly access protected members of a superclass.

(True/False)
4.8/5
(40)

A subclass can override public methods of a superclass.

(True/False)
4.9/5
(36)

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

A subclass inherits all its data members from the superclass; it has none of its own.

(True/False)
4.9/5
(44)

Inheritance implies an "is-a" relationship.

(True/False)
4.7/5
(36)

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

In Java, stream classes are implemented using the inheritance mechanism.

(True/False)
4.9/5
(41)

An abstract method ____.

(Multiple Choice)
4.8/5
(47)

A subclass can directly access ____.

(Multiple Choice)
4.8/5
(46)

In Java, polymorphism is implemented using late binding.

(True/False)
4.8/5
(28)

An abstract class can contain ____.

(Multiple Choice)
4.9/5
(40)

What type of inheritance does Java support?

(Multiple Choice)
4.8/5
(31)

In multiple inheritance, the subclass is derived from more than one superclass.

(True/False)
4.8/5
(37)

Composition is a "has-a" relationship.

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

Filters

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