Sobes.tech
Junior — Senior

Analysis of class behavior during initialization – Example #1

livecode

Task condition

Describe how the given code works and predict what output will appear in the console when it is run.

class Cat {
    val name: String

    init {
        printName()
        name = "Murzik"
    }

    private fun printName() {
        println(name)
    }
}

fun main() {
    Cat()
}