I was going through the Object class JAVA-docs and as we know Object is base class of all classes. But i was wondering, When Object class is added as super class? Is it compile time or runtime(believe ideally it should be at compile time)?
Also as i have read JVM automatically checks if a class is inheriting from parent class then it will not add Object as super class to avoid Inheritance-diamond problem but what will happen in case of abstract class/ inner classes? Where will be Super class-Object will be added ?
While creating any new built in objects example HashMap we can see the internal working from the source, Similarly is it possible to see this functionality anywhere in Java source code or it is done by compiler internally ?
If you don't specify a super class, the default is java.lang.Object
. And the super class is determined at compile time. In the case of an abstract
(an inner
or a static
) class, without an explicit super type; the super type is java.lang.Object
.