English
Topic 6. Inheritance, polymorphism, and the Object class
Goal: learn to build correct hierarchies, override methods, handle subtypes through a shared contract, and check object equality.
Lecture contents
- Subclasses and their constructors — Shared behavior of domain types · The subclass constructor and base portion · Example 1. Employee payroll
- Overriding and type casts — Protected access does not mean public · Overriding, overloading, and hiding · Example 2. Shapes and safe casts
- Object, equality, and copying — Object and logical equality · Example 3. An immutable point as a value · Copying: references, fields, and nested objects
- Composition and the substitution principle — Composition and the substitution principle · Example 4. A stack through composition · Inspecting the hierarchy in IntelliJ IDEA