Phase VII
The Four Pillars
Closing objects off, building on them, and letting them choose their own behaviour.
Protect object invariants, model honest parent-child relationships, and write callers against shared contracts. Then study wrapper conversions and all four nested-class forms, including their access, capture, and lifetime rules.
When you finish this phase you can
- Protect invariants with operations instead of exposing fields through routine setters
- Apply private, package-private, protected, and public access accurately
- Trace superclass construction and use super for constructors and parent implementations
- Separate compile-time overload selection from run-time override dispatch
- Choose an abstract class or interface from state, hierarchy, and capability needs
- Expand boxing and unboxing to diagnose identity, null, overload, and performance traps
- Choose among static nested, inner, local, and anonymous classes by access and lifetime
- Explain why lambdas replace many anonymous-class uses but are not anonymous classes
- 7.1Encapsulation, Inheritance, Packages, and `super`Protect an object's rules and move genuinely shared behaviour into a parent class.EncapsulationInheritance
- 7.2Abstraction, Polymorphism, Abstract Classes, and InterfacesUse one parent type while each child object provides its own behaviour.PolymorphismAbstract classInterface
- 7.3Wrapper Types, Autoboxing, and POJOsSee when Java converts between primitives and wrapper objects, and avoid equality and null errors.AutoboxingPOJO
- 7.4Static Nested, Inner, Local, and Anonymous ClassesChoose a nested-class form from the data and enclosing object it needs to access.Anonymous classInner class