I know super is a special reserved keyword but from the way how we use it , it should be called as object. Can some one clarify whether my thought is right or wrong. Would be better if you can provide more detailed clarification on this.
That would not be correct. Super is a keyword in java used to reference the superclass of the instance of a class. Object is an instance of a class.
You cannot use the word "super" unless an instance of a class exist, therefore, it cannot be considered equivalent to an object.
Think of a hypothetical class Human
. You can ask me "what's your superclass" and I would say "it's Creature
". But you cannot "create" a new Human
by asking "what's your superclass".
Maybe your confusion comes from the usage of the word "super" in the constructor. When we make the super();
call, we're actually executing the superclass's constructor. As you know, constructors are very particular methods and they are not invoked the same way another method would have been. If I was to refer to a getter of the superclass, I would do super.getWhatever();
instead. However, we cannot do super.something()
to call a constructor, so we just do super();
.
And regarding the call to the superclass's constructor when constructing an instance of a class, that's because you cannot call me "Human" before defining me as a "Creature". So, you first create the creature characteristics on me and then you make me human.
I hope that makes sense :).