In which of these examples is inheritance utilized correctly (i.e., does not cause any errors)?
#1
interface MyInterface {
val myProperty: Int = 10
fun myMethod(): Int = 10
fun mySecondMethod() { print("Hola!") }
}
class MyClass : MyInterface {
override val myProperty: Int
get() = 11
}
#2
interface MyInterface {
val myProperty: Int
fun myMethod(): Int
fun mySecondMethod() { print("Hola!") }
}
class MyClass : MyInterface {
override val myProperty: Int = 10
fun myNewMethod(): 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 {
override val myProperty: Int = 10
}