Lovely bounds

Report a typo

Take a look at the code snippet below:

fun main() {
    var cat = Cat("Kitty")
    var book = Book("Harry Potter")
    printTypeBound(cat)
    printTypeBound(book)
}

fun <T : Animal> printTypeBound(item: T) {
    println(item.name)
}


open class Animal(var name: String)
class Cat(name: String) : Animal(name)
class Book(name: String)

What will be the result of its compilation and execution? Choose the right answer.

Select one option from the list
___

Create a free account to access the full topic