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
{
}
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible.
Submit your tip here.