Chapter 9 Flashcards

1
Q

Employing inheritance reduces errors because

A

Baby of the methods a subclass needs have already been used and tested

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A base class can also be called a

A

Superclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an example of a parent class/child class relationship?

A

BodyOfWater/River

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A class named Building has public, no static method named getFloors(). If School is a child class of Building, and modelHigh is an object of type School, is modelHigh.getFloors() valid?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When a subclass method has the same name and argument types as a super class method, the subclass method ______ the superclass method.

A

Overrides

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When you instantiate an object that is a member of a subclass, the ______ constructor executes first.

A

Parent class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If you only constructor in a superclass requires arguments, its subclass

A

Must contain a constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A child class Motorcycle extends a parent class Vehicle. Each class constructor requires one String argument. The Motorcycle class constructor can call the Vehicle class constructor with the statement

A

Super(“Suzuki”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If you create a data field or method that is ______, it can be used within its own class or in any classes extended from that class.

A

Public or protected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

You use a _____ method access specifier when you create methods for which you want to prevent overriding in extended classes.

A

Final

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When a parent class contains a static method, child classes ______ override it.

A

Cannot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Abstract classes differ from other classes in that you

A

Cannot instantiate objects from them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

An abstract class Dwelling has two subclasses, SingleFamily and MultiFamily. None of the constructors for these classes requires any arguments. Is SingleFamily myHome = new SingleFamily() valid?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

An abstract class Employee has two subclasses, Permanent and Temporary. The Employee class contains an abstract method named setType(). Before you can instantiate Permanent and Temporary objects, what is true?

A

You must code statements for the setType() method within both the Permanent and Temporary classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Super class ________ contain abstract methods.

A

Can

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When you create a ______ in Java, you create a variable name in which you can hold the memory address of an object.

A

Reference

17
Q

An application’s ability to select the correct subclass method to execute is known as ________ method binding.

A

Dynamic

18
Q

You ________ override the toString() method in any class you create.

A

Can

19
Q

The Object class equals() method takes

A

One argument

20
Q

The alternative to multiple inheritance in Java is known as a(n)

A

Interface