October 2018
Intermediate to advanced
370 pages
9h 15m
English
An abstract class is a generic concept and it does not belong to a concrete idea. We do not create an instance of an abstract class; its only responsibility is to facilitate the creation of other classes. An abstract class is used to define which behaviors a class should have instead of how it should be implemented. Take a look at the following example from the previous section:
open class Person (val fName: String, var lName: String, var pAge: Int) { fun speak() { println("My name is $fName $lName age is $pAge") } fun greet() { println("Hi there...$fName ") } } class Student(fName: String, lName: String, pAge: Int , val studentId : String) : Person(fName,lName,pAge) { ... ...}
Notice that the Person class is a normal class ...
Read now
Unlock full access