Chapter 9 Quiz Flashcards Preview

COP_3252 > Chapter 9 Quiz > Flashcards

Flashcards in Chapter 9 Quiz Deck (22):
1

Every class in Java, except ________, extends an existing.

Objects

2

Which superclass members are inherited by all subclasses of that superclass?
a. private instance variables and methods.
b. protected instance variables and methods.
c. private constructors.
d. protected constructors.

b. protected instance variables and methods.

3



Using the protected keyword gives a member:

private access
package access
block scope
public access

package access

4

Overriding a method differs from overloading a method because:

Overridden methods have the same signature

5

Superclass methods with this level of access cannot be called from subclasses

Private

6

The default implementation of method clone of Object performs a ________.

shallow copy

7

When a subclass constructor calls its superclass constructor, what happens if the superclass’s constructor does not assign a value to an instance variable?

The program compiles and runs because the instance variables are initialized to their default values

8

Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?

super

9

Inheritance is also known as the _______
a. knows-a relationship.
b. has-a relationship.
c. uses-a relationship.
d. is-a relationship.

d. Inheritance is known as the is-a relationship.

10

Which of the following is not a superclass/subclass relationship?
a. Employee/Hourly Employee.
b. Vehicle/Car.
c. Sailboat/Tugboat.
d. None of the above.

c. Sailboat/Tugboat (they are both different type of boats, they would both be subclasses of superclass boat.)

11

Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?
a. base.
b. this.
c. public.
d. super.

d. super (must be called in the default constructor of the subclass)

12

Superclass methods with this level of access cannot be called from subclasses.
a. private.
b. public.
c. protected.
d. package.

a. Private level access

13

private fields of a superclass can be accessed in a subclass
a. by calling private methods declared in the superclass.
b. by calling public or protected methods declared in the superclass.
c. directly.
d. All of the above.

b. By calling public or protected methods in the super class.

14

When overriding a superclass method and calling the superclass version from the subclass method, failure to prefix the superclass method name with the keyword super and a dot (.) in the superclass method call causes ________.
a. a compile-time error.
b. a syntax error.
c. infinite recursion.
d. a runtime error.

c. Infinite Recursion

15

A form of software reuse in which existing classes acquire the member of existing classes and embellish those classes with new capabilities.

Inheritance

16

What members of a super class can be accessed in the superclasses's declarations and in the subclass declarations.

protected (public variables may be accessed as well but, this is a bad practice)

17

In a _________________ relationship a subclass object can be treated as an object of its superclass.

Inheritance(is-a)

18

In a ________________ relationship a class object has references to objects of other classes as members.

composition(has-a)

19

in single inheritance a class exists in a(n)_________ relationship with its subclasses

is - a

20

A superclasses's _____________ members can be accessed anywhere the program has a reference to an object of that superclass or to an object of one of its subclasses

public

21

When an object of a subclass is instantiated, a superclass _____________ is called implicitly or explicitly.

constructor

22

Subclass constructors can call superclass constructors via the ________________ keyword.

Super