Can you tell me what the output is going to be? This question is for somebody who is going to take the exam and not for gurus.
But i do have a question for the gurus. If i add super() in the constructor of SubClass, the output is the same. Even if you don't write a super() in a subclass, it is anyway going to invoke the default constructor of the immediate inherited class. Then what else is the use of super in a constructor?
It will print 'class test.SubClass instance created.' followed by 'Printing...' followed by 'class test.SubClass instance created.' as the output. The first line is printed from the superclass because the constructor of a superclass is called before a subclass's constructor, in other words, you cannot instantiate a subclass before instantiating its superclass.
You can use super to call your desired constructor from the sub class.
hope it helps?
[ March 21, 2005: Message edited by: Parimal Sharma ] [ March 22, 2005: Message edited by: Parimal Sharma ]