Sobes.tech
Junior — Middle

Kotlinis peamiseadistuse järgi, kas klassid loetakse suletud või avatud pärandamiseks?

sobes.tech AI

Vastus AI-lt

In Kotlin, by default, all classes are closed (final), meaning they cannot be inherited without explicit declaration.

To make a class inheritable, it must be declared with the open modifier:

open class BaseClass {
    // class body
}

class DerivedClass : BaseClass() {
    // inheritor
}

This is done to increase safety and prevent unintentional inheritance, which improves control over the class hierarchy.