Understanding class delegation in Kotlin

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Consider the following Kotlin code snippet:
interface Base {
    fun print()
}
class BaseImpl(val x: Int) : Base {
    override fun print() { print(x) }
}
class Derived(b: Base) : Base by b
val b = BaseImpl(10)
Derived(b).print()
What is the output of the `Derived(b).print()` line and why?
Select one option from the list

Create a free account to access the full topic