#4 inheritance + cmsc131 review Flashcards

1
Q

keyword: extends

A

a class can be defined from an existing class (using key word extends)

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

original class is called

A

base class, parent class, superclass

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

class defined from original class is called

A

derived class, child class, subclass

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

what does/can a subclass do

A

inherits all fields and methods of superclass, can only extend one super class

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

subclass constructor

A

subclass constructor automatically calls its superclass’ default constructor (if superclass has no default constructor, you get an ERROR)

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

keyword: super

A

subclass constructor can explicitly invoke a (different) superclass constructor using “super” (it’s okay if superclass doesn’t have a constructor)

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

can a superclass object refer to any (direct or indirect) subclass object

A

YES! b/c a subclass object is a type of superclass object. A superclass can refer to both a superclass object and a subclass object

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

can a subclass object refer to a superclass object

A

NO! b/c a superclass is not a type of subclass

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

objectName insanceof className

A

if true, the object is of type class-name or its (direct or indirect) subclasses

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

objectName.getClass()

A

returns reference to a class object (can be compared (w/ equals() or == ) to see if objects are from the exact same class(not subclass))

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