17 Interfaces and Abstract Classes
In this chapter you will see how to define and use interfaces and abstract classes in Kotlin.
An interface allows you to specify common properties and behavior that are supported by a subset of classes in your program – without being required to specify how they will be implemented. This capability – the what without the how – is useful when inheritance is not the right relationship for classes in a program. Using an interface, a group of classes can have properties or functions in common without sharing a superclass or subclassing one another.
You will also work with a type of class called an abstract class, a hybrid between the features of interfaces and classes. Abstract classes are similar ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access