In Kotlin, abstract class is declared using the abstract keyword in front of class. An abstract class can not instantiated means we can not create object for the abstract class.
* We can’t create an object for abstract class.
* An abstract class can contain both abstract and non-abstract members
* All the variables (properties) and member functions of an abstract class are by default non-abstract. So, if we want to override these members in the child class then we need to use open keyword.
* If we declare a member function as abstract then we does not need to annotate with open keyword because these are open by default.
* An abstract member function doesn’t have a body, and it must be implemented in the derived class.
```
abstract class Employee(val name: String,val experience: Int) {
abstract var salary: Double
abstract var date: String
abstract fun dateOfBirth(date:String)
fun employeeDetails() {
println("Name of the employee: $name")
println("Experience in years: $experience")
println("Annual Salary: $salary")
println("Birth date: $date")
}
}
class Engineer(name: String, experience: Int) : Employee(name,experience) {
override var salary = 500000.00
override var date = ""
override fun dateOfBirth(date:String){
this.date = date;
}
}
fun main() {
val eng = Engineer("Tom",2)
eng.dateOfBirth("02 December 1994")
eng.employeeDetails()
}
```