8.1-1_Understanding Inheritance Flashcards

1
Q

What is Inheritance?

A

Inheritance is the process by which a class is subscribed as a childclass from another class called parentclass, and by this it automatically includes any accessible (public|protected|default?) members defined in that parent class.

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

What is called a class that inherits from another class?

A

A subclass or child class

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

What is called a class that the child inherits from?

A

The superclass or parent class

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

What does single inheritance means?

A
A class may inherit from only one direct parent class. 
⚠️🤯️ Java doesn't allow multiple inheritance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does multiple inheritance means?

A

A class may have multiple direct parents.

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

How to prevent a class from being extended?

A

By marking the class with the final modifier.

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

What happens if you try to define a class that inherits from a final class?

A

❌ The class will fail to compile.

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