Sobes.tech
Junior — Middle

Which class in Kotlin is inherited by all other classes by default?

sobes.tech AI

Answer from AI

In Kotlin, all classes by default inherit from the Any class. This is the base class that provides methods:

  • equals()
  • hashCode()
  • toString()

If a class does not explicitly inherit from another class, it implicitly inherits from Any.

Example:

class MyClass {
    // implicitly inherits from Any
}

val obj = MyClass()
println(obj.toString()) // calls the method from Any
Which class in Kotlin is inherited by all other… - sobes.tech