belongs to collection: Kotlin Class and Object Programs
package com.includehelp // Declare Interface interface AA{ // Abstract property val count:Int // Abstract methods fun sayHello() // Method with implementation fun sayGudMorning(){ println("Gud Morning, IncludeHelp !!") } } // Derived interface from another super interface interface BB:AA{ // Abstract methods fun sayBye() // Override Interface abstract methods, // declare into super interface override fun sayHello() { println("Hello, IncludeHelp !!") } } // Declare class implementing interface class IncludeHelp:BB{ // Override abstract property override val count: Int get() = 100 // Override Interface abstract methods override fun sayBye() { println("Gud Bye, IncludeHelp !!") } } // Main function, entry point of program fun main(){ // Create instance of class val includeHelp = IncludeHelp() // Call method includeHelp.sayGudMorning() // Call method includeHelp.sayHello() // Call method includeHelp.sayBye() println("Abstract Property : ${includeHelp.count}") }
Output:
Gud Morning, IncludeHelp !! Hello, IncludeHelp !! Gud Bye, IncludeHelp !! Abstract Property : 100
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program demonstrate the example of Inheritance within Interface in Kotlin
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer