Implementing without errors: find what's wrong

Report a typo

In which of these examples is inheritance utilized correctly (i.e., does not cause any errors)?

#1

interface MyInterface {
    val myProperty: Int
    fun myMethod(): Int
    fun mySecondMethod() { print("Hola!") }
}

class MyClass : MyInterface {}

#2

interface MyInterface {
    val myProperty: Int
    fun myMethod(): Int = 10
    fun mySecondMethod() { print("Hola!") }
}

class MyClass : MyInterface {
    override val myProperty: Int = 10

    override fun myMethod(): Int { return 11 }

    override fun mySecondMethod() { print("Hi") }
}

#3

interface MyInterface {
    val myProperty: Int
    fun myMethod(): Int = 10
    fun mySecondMethod() { print("Hola!") }
}

class MyClass : MyInterface {}
Select one option from the list
___

Create a free account to access the full topic