Junior — Middle
What is the base class that is the ancestor of all classes in Kotlin?
sobes.tech AI
Answer from AI
In Kotlin, the base class that is the ancestor of all classes is the Any class. It is similar to the Object class in Java, but it only contains three methods: equals(), hashCode(), and toString(). All classes in Kotlin implicitly inherit from Any unless specified otherwise.
Example:
class MyClass
fun main() {
val obj = MyClass()
println(obj.toString()) // The toString() method from the Any class
}