Messy inheritance

Report a typo

Which of these examples utilize interface inheritance incorrectly, causing compilation errors?

#1

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

interface MyInterface2 {
    val myProperty: Int
    fun myThirdMethod() = print("Hola amigos!")
}

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

    override fun myMethod(): Int { return 127312 }

    override fun mySecondMethod() { print("Hello.") }
}

#2

interface MyInterface {
    val myProperty: Int
        get() = 10

    fun myMethod(): Int = 10
    fun mySecondMethod() { print("Hola!") }
}

interface MyInterface2 {
    val myProperty: Int
        get() = 15

    fun myThirdMethod() = print("Hola amigos!")
}

class MyClass : MyInterface, MyInterface2 {}

#3

interface MyInterface {
    val myProperty: Int
        get() = 10

    fun myMethod(): Int = 10
    fun mySecondMethod() { print("Hola!") }
}

interface MyInterface2 {
    val myProperty: Int
        get() = 15

    fun myThirdMethod() = print("Hola amigos!")
}

class MyClass : MyInterface, MyInterface2 {
    override val myProperty: Int = 10
}

#4

interface MyInterface {
    val myProperty: Int
        get() = 10

    fun myMethod(): Int = 10
    fun mySecondMethod() { print("Hola!") }
}

interface MyInterface2 {
    val myProperty: Int
        get() = 15

    fun myThirdMethod() = print("Hola amigos!")
}

class MyClass : MyInterface, MyInterface2 {
    override val myProperty: Int = 10
    override fun myMethod(): Int { return myProperty }
    override fun mySecondMethod() { print("Hello") }
    override fun myThirdMethod() { print("Hello people!") }
}
Select one option from the list
___

Create a free account to access the full topic