8.1-1_Understanding Inheritance Flashcards
What is Inheritance?
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.
What is called a class that inherits from another class?
A subclass or child class
What is called a class that the child inherits from?
The superclass or parent class
What does single inheritance means?
A class may inherit from only one direct parent class. ⚠️🤯️ Java doesn't allow multiple inheritance
What does multiple inheritance means?
A class may have multiple direct parents.
How to prevent a class from being extended?
By marking the class with the final modifier.
What happens if you try to define a class that inherits from a final class?
❌ The class will fail to compile.