A call to super() which has to be the first statement in the constructor, creates [gross oversimplification] that part of the object which is inherited. In most subclasses a super() call is essential.
A new Superclass() call creates a new object of the superclass completely separate from where one is working at present.
krishna prasad gunasekaran
Joined: Jul 25, 2006
so a call to super() doesn't necessarily create a superclass object. Right? does the superclass constructor run? absolutely, it will.
tell me whether i'm right. a call to constructor doesn't create an object. it's only a syntactic way of telling the jvm that we need an object and also gives us a way to initialize instance variable. we can perform both operations simultaneously. that's the use of constructors. that is we are initializing the instance variables immediately after object creation.
am i right?
Joined: Oct 13, 2005
I think I agree with what you say. I find it a bit difficult to understand, however.
subject: object creation with super() and constructor