revised: 10/05/03, 11/02/2012

Quiz on Interfaces

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 is an interface?

A.    An interface is a collection of constants and method declarations.

B.    An interface is a class that a child class can extend.

C.    An interface is a collection of GUI components.

D.    An interface is the collection of public methods of a class.

2. When a class implements an interface, what must it do?

A.    It must redefine each constant from the interface.

B.    It must declare and provide a method body for each method in the interface.

C.    It must declare a variable for each constant in the interface.

D.    It must include a private method for each method in the interface.

3. Is the following a correct way to start out a class definition:

public class SomeClass implements MyInterface

A.    No—SomeClass must also extend a base class.

B.    No—SomeClass cannot be public if it implements an interface

C.    Yes—SomeClass is a child of MyInterface

D.    Yes—SomeClass is automatically a child of the class Object.

4. Can an interface name be used as the type of a variable, like this:

public static void main( String[] args )
  SomeInterface x;


A.    No—a variable must always be an object reference type.

B.    No—a variable must always be an object reference type or a primitive type.

C.    No—a variable must always be a primitive type.

D.    Yes—the variable can refer to any object whose class implements the interface.

5. Can an interface be given the private access modifier?

A.    No—then the interface could never be used.

B.    No—since only private classes could use the interface.

C.    Yes—this would make all of its methods and constants private.

D.    Yes—this would mean that only classes in the same file could use the interface.

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.