October 2018
Intermediate to advanced
370 pages
9h 15m
English
To open classes in Kotlin, we can add the open keyword at the beginning of the superclass signatures:
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, pAge: Int, ID: String ): Person(fName,lName,pAge, ID) { fun aboutEducation(){ println("I am a student of Computer Science.") } fun attendLectures() { println("I am studying Introduction to Kotlin lecture.") }}
Now, the Student child class has access to all the functions of the Person class, and has its own properties and functions as well. We will add two functions ...
Read now
Unlock full access