Inheritance & Polymorphism
In this section, we consider the idea that classes can inherit attributes and behaviour from other classes, adding their own attributes and behaviour as well as altering the behaviour they have inherited.
We look at how to create these ‘subclasses’ in Kotlin. We also look at the impact of overriding inherited methods a subclass. This leads us to an extended example, a graphics application that demonstrates the concepts of dynamic binding and polymorphism.
We conclude the section by examining the idea of multiple inheritance and explaining why Kotlin doesn’t support this feature.