Chapter 7 – Inheritance Flashcards

1
Q

inheritance

A

Inheritance means that a very general form of a class can be defined and compiled. Later, more specialized versions of that class may be defined by starting with the already defined class and adding more specialized instance variables and methods. The specialized classes are said to inherit the methods and instance variables of the previously defined general class.

A derived class automatically has all the instance variables, all the static variables, and all the public methods of the base class. These members from the base class are said to be inherited. These inherited methods and inherited instance and static variables are, with one exception, not mentioned in the definition of the derived class, but they are automatically members of the derived class. The one exception is as follows: As explained in the subsection “Overriding a Method Definition,” you can give a definition for an inherited method in the definition of the derived class; this will redefine the meaning of the method for the derived class.

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

derived class

A

A derived class is a class defined by adding instance variables and methods to an existing class.

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

base class

A

The existing class that the derived class is built upon is called the base class.

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

extends

A
The way we indicate that HourlyEmployee is a derived class of Employee is by including the phrase extends Employee on the first line of the class definition, like so:
>public class HourlyEmployee extends Employee
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

subclass and superclass

A

A derived class is also called a subclass, in which case the base class is usually called a superclass. However, we prefer to use the terms derived class and base class.

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

parent class

A

A base class is often called the parent class.

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

child class

A

A derived class is then called a child class.

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

ancestor class

A

A class that is a parent of a parent of a parent of another class (or some other number of “parent of” iterations) is often called an ancestor class.

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

descendent class

A

If class A is an ancestor of class B, then class B is often called a descendent of class A.

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

overriding

A

A derived class inherits methods that belong to the base class. However, if a derived class requires a different definition for an inherited method, the method may be redefined in the derived class. This is called overriding the method definition.

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

covariant return type

A

When overriding a class method in a derived class, you are not allowed to change the return type of the method, and you can’t make a void return non-void or vice versa. An exception to this changed return type is known as a covariant return type: when you override the function definition in a derived class that returns a class, you may change the returned type.

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

super

A

.

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

this

A

.

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

“is a” relationship

A

.

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

subclass and superclass

A

.

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

“has a” relationship

A

.

17
Q

composition

A

.

18
Q

super relationship

A

.

19
Q

object class

A

.

20
Q

toString

A

.

21
Q

equals

A

.

22
Q

clone

A

.

23
Q

instanceof

A

.