English
Summary
Conclusions
A common type lets you write an algorithm once, while concrete objects supply the required behavior. An abstract class is useful for shared state and an algorithm; an interface is useful for an independent capability. Inheritance requires a substitution contract, while composition often offers a simpler separation of responsibilities.
Self-check questions
- Why does Kotlin make classes final by default?
- What does the static type determine, and what does the object's actual type determine?
- Why does a super call not disable all polymorphic calls?
- What members can an abstract class have?
- Why does an interface not store its own property backing field?
- How do you resolve a conflict between two default implementations?
- When is a smart cast impossible, and why does a local val help?
- How are equals and hashCode related?
- Why is an open call in a base class's init block dangerous?
- What promise does an incorrect subtype violate?