October 2019
Intermediate to advanced
434 pages
11h 54m
English
In Kotlin, we can define abstract classes and inherit from classes to model data and create class hierarchies. Conceptually, this is the same as in Java, but there are a few differences in how these mechanisms work in Kotlin.
If we want to define a class that implements an interface but doesn't provide implementations for all of the required methods, we can mark the class as abstract:
interface Shape { fun getArea() : Double}abstract class Rectangle : Shape
Classes in Kotlin are closed by default. This means that, for a class to be extended, it must use the open keyword. The open keyword will indicate to the compiler that a class is open for extension:
open class Rectangle( val width: Double, val height: ...
Read now
Unlock full access