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, then share a genuine parent type without losing control of construction.EncapsulationInheritance
- 7.2Abstraction, Polymorphism, Abstract Classes, and InterfacesProgram to a shared contract while each object keeps its own implementation.PolymorphismAbstract classInterface
- 7.3Wrapper Types, Autoboxing, and POJOsSee every hidden primitive conversion, avoid identity and null traps, and separate Java objects from framework rules.AutoboxingPOJO
- 7.4Static Nested, Inner, Local, and Anonymous ClassesChoose the right nesting form by asking about scope, the enclosing object, and captured values.Anonymous classInner class