Card 10/ 10
Recap: Inheritance
What extends gives, constructor order, overriding, super and private, with where each was.
Inheritance comes down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| A subclass gets the parent's members but not its constructors | Java Inheritance: What extends Gives a Subclass |
| Constructors are entered downwards and complete upwards, most general first | Constructor Chaining: Parent Constructors Finish First |
| Same name and same parameter list is overriding; a different list is overloading | Overriding vs Overloading |
super(...) is inserted for you, and super.method() reaches one level up | The super Keyword: Parent Methods and Parent Constructors |
A private parent field exists in the object and cannot be named by the subclass | Why a Subclass Cannot Name a private Parent Field |
extends decides what an object contains, and access modifiers decide what your source may name. Those are two different questions, and almost every confusing inheritance error is one of them mistaken for the other.
← → move through sections and cards