October 2018
Intermediate to advanced
370 pages
9h 15m
English
A situation in which a parent class is inherited by many subclasses is called hierarchical inheritance. This is shown in the following diagram, where A is a parent class and B, C, and D are child classes. In this inheritance model, two or more classes are derived from the parent class:

Create a superclass, Person, and two derived classes, Student and Employee:
open class Person (val fName: String, var lName: String, var pAge: Int, val ID : String) { fun speak() { println("My name is $fName $lName, my id is $ID and age is $pAge") } fun greet() { println("Hi How are you...") }}class Student(fName: String, lName: String, ...
Read now
Unlock full access