All Java classes that don't have any explicit superclass, extend from Object
, except for Object
itself. There's no need to make it explicit in your code, the compiler will take care of.
Also, the super()
call in the constructor will invoke the constructor of Object
. If you look at the implementation, you'll see that Object doesn't have any constructor at all, so it'll use an implicit empty constructor which does nothing. Details such as constructing a vtable to make sure that the inherited methods are there to use or initialising the object's monitor are not part of the constructor but are performed by the JVM implementation when the new
operator is called.
public Object() {
}
The Object class has few methods that come handy in most of the classes. For example, the infamous toString()
is implemented in the Object class. Also, the hashCode()
is implemented there.
I'd recommend you to have a deep look at the Object.class file to understand what methods are inherited in every single Java class.
Regarding your 3 rules at the top, are "good" for academic purposes but never used in reality. You'll never see an explicit extends Object
, and only call the super()
or this()
when you need to overwrite the default behaviour.
Also, avoid abusing of inheritance and use more composition (implement an interface), although, it depends on the every use case.