By
using super keyword, you can call super class methods.
Syntax
super.methodName
SuperDemo.kt
open class BaseClass { open fun printMsg() { println("Hello Base class") } } open class DerivedClass : BaseClass() { override fun printMsg() { println("Hello Derived class") super.printMsg() } } fun main(args: Array<String>) { var obj = DerivedClass() obj.printMsg() }
Output
Hello Derived class Hello Base class
No comments:
Post a Comment