Which class is a superclass of all classes?
1098
24-Nov-2021
Updated on 16-Jun-2023
Aryan Kumar
16-Jun-2023The Object class is the superclass of all classes in Java. It is located in the java.lang package. All classes, including arrays, inherit from the Object class. This means that all classes have the methods and properties of the Object class, even if they do not explicitly reference them.
The Object class provides a number of methods and properties that are common to all objects, such as the equals, hashCode, and toString methods. It also provides the finalize method, which is called by the garbage collector when an object is about to be garbage collected.
The Object class is an abstract class, which means that it cannot be instantiated. However, it is still an important class in Java, as it provides the foundation for all other classes.
Here are some of the methods and properties of the Object class:
Mukul Goenka
24-Nov-2021Java.lang package, The object is the root class for all the java classes and we don’t need to extend it. Every other java classes fall back under the object. All the different non-primitive types including arrays are inherited directly or indirectly from this class.