revised: 10/05/03

Quiz on Inheritance

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. What type of inheritance does Java have?

A.    single inheritance

B.    double inheritance

C.    multiple inheritance

D.    class inheritance

2. Can an object be a subclass of another object?

A.    Yes—as long as single inheritance is followed.

B.    No—inheritance is only between classes.

C.    Only when one has been defined in terms of the other.

D.    Yes—when one object is used in the constructor of another.

3. What restriction is there on using the super reference in a constructor?

A.    It can only be used in the parent's constructor.

B.    Only one child class can use it.

C.    It must be used in the last statement of the constructor.

D.    It must be used in the first statement of the constructor.

4. A class Car and its subclass Yugo both have a method run() which was written by the programmer as part of the class definition. If junker refers to an object of type Yugo, what will the following code do?;

A.    The show() method defined in Yugo will be called.

B.    The show() method defined in Car will be called.

C.    The compiler will complain that run() has been defined twice.

D.    Overloading will be used to pick which run() is called.

5. Does a subclass inherit both member variables and methods?

A.    No—only member variables are inherited.

B.    No—only methods are inherited.

C.    Yes—both are inherited.

D.    Yes—but only one or the other are inherited.

The number you got right:       Percent Correct:       Letter Grade:   

Click here If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.