top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How object class is inherited into all the Java class without having extends Keyword?

+1 vote
416 views

How object class is inherited into all the Java class without having extends Keyword. I mean what is the logic for making a class to inherit to all the other classes.

posted Jun 24, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

if you don't explicitly write extends Object the compiler does it for you. So knowing that a class can only extend one super class, the compiler will look at the hierarchy and extend the highest super class to Object. So every class will directly or indirectly inherit the Object class.

The Object class however is a special case because it doesn't extend anything.

Lastly if you were to compile a simple class and decompile it, you will see the compiler inserts extends
java.lang.Object (or the bytecode equivalent) into the class.

answer Jul 1, 2015 by Karthick.c
...