The Object class in Java is a superclass for all other classes defined in Java’s class libraries, as well as for user-defined Java classes. In object-oriented terms, an object is an instance of a class. Note the distinction between the “Object class” and a Java “object”: A Java object is an instance of any class derived from the Object class.
Normally, when a class is defined in Java, the inheritance from the Object class is implicit. Therefore, the following two declarations of class “MyClass” are equivalent:
public class MyClass{}public class MyClass extends Object{}
In fact, the second class declaration is redundant and shouldn’t be used. Note that inheriting from the Object class is the only exception to Java’s rule for single inheritance. Java’s inheritance mechanism allows a class to extend from only one superclass (although it may implement several interfaces). However, the following statement is valid, even though it implies that MyClass extends from two Java classes (the “Object” class and “Superclass”):
public class MyClass extends SuperClass{}