Junior — Middle
Which class in Kotlin is the base and inherited by all other classes?
sobes.tech AI
Answer from AI
In Kotlin, the base class from which all other classes implicitly inherit is the Any class. It is analogous to the Object class in Java.
The Any class contains three default methods:
equals()— for comparing objectshashCode()— for obtaining the hash code of an objecttoString()— for obtaining the string representation of an object
Example:
fun main() {
val obj: Any = "Example"
println(obj.toString()) // Outputs: Example
}