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

Correct Answer:

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.

Correct Answer:

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 in the first statement of the constructor.

Correct Answer:

4. A class Car has a subclass Honda. Both classes include a run() method as part of the class definition. If wheels refers to an object of type Honda, what will the following code do?;

A.    The run() method defined in Honda will be called.

B.    The run() 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.

Correct Answer:

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.

Correct Answer:

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.