Inheritance and Polymorphism Flashcards

1
Q

Inheritance relationship explained.

A

“Is-a”. I.e. Tiger is a mammal is an animal.

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

What is low cohesion?

A

One class does too many things.

Ideally, each class does one thing well.

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

What is high coupling?

A

When classes make lots of calls between each other.

Ideally, the number of calls between classes is limited.

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

Inheritance java syntax.

A

pubic class Parent {
// implementation
}

public class Child extends Parent {
// implementation
}

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

What does every class in java inherit from?

A

Either directly or indirectly, they all inherit form Object.

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

How to check if an object is an instance of a specified type?

A

Use instanceof
I.e. anObject instanceof Type

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

How to redefine a method in a subclass?

A

use @Override before the method. (may be optional in Java, but apparently used for javadocs).

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