October 2018
Intermediate to advanced
370 pages
9h 15m
English
So far, all classes were inherited using a primary constructor. If the Student class doesn't have a primary constructor but a secondary constructor instead, the secondary constructor can be preceded by the super keyword:
class Student: Person { constructor(fName: String,lName: String, age: Int, id: String) : super(fName,lName,age, id) fun aboutEducation(){ println("I am a student of Computer Science.") } fun attendLectures() { println("I am studding Introduction to Kotlin lecture.") }}
The super keyword will call the constructor of the super or parent class to initialize the properties of the parent class.
Read now
Unlock full access