Sobes.tech
Junior — Middle

What is the root class for all objects in Java?

sobes.tech AI

Answer from AI

In Java, the root class for all objects is java.lang.Object. All classes in Java implicitly inherit from this class, which allows using methods defined in Object, such as toString(), equals(), hashCode(), and others.

Example:

public class Example {
    public static void main(String[] args) {
        Object obj = new Object();
        System.out.println(obj.toString());
    }
}