English
Topic 6. Inheritance, abstract classes, interfaces, and polymorphism
Goal: create class hierarchies and interface contracts; use overriding, polymorphic algorithms, and consistent object equality.
Lecture contents
- A common type and open classes — Why a program needs a common type · Classes are closed by default · Dynamic dispatch
- Abstract classes — An abstract class and a complete hierarchy
- Interfaces and implementation conflicts — An interface: a capability without a shared field · Conflicting default implementations
- Type casts, Any, and initialization — Type checks and safe casts · Any: equality, hashing, and string representation · Initialization and unsafe open calls
- The template method and hierarchy testing — The template method and composition · UML and hierarchy testing · Designing a contract test