Card 08/ 08
Recap: Interfaces and Abstract Classes
Capabilities, shared state, the deciding question, default methods and single inheritance, with where each was.
Interfaces and abstract classes come down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| An interface names a capability and holds no per-object state | Java Interfaces: Naming a Capability Without an Implementation |
| An abstract class is a partly built class, with fields and a constructor | Abstract Classes: Shared State and a Fixed Sequence |
| The deciding question is whether there is shared state | Interface vs Abstract Class |
A default method lets an interface grow without breaking implementations | Default Methods in Java Interfaces |
One extends, any number of implements, because interfaces add no fields | Single Inheritance: One extends, Many implements |
State is the whole distinction. How many you may have, what a default method may touch, and why constants in an interface are shared all follow from an interface having none.
← → move through sections and cards