posted 20 years ago
Hi This qn is from Mindq.http://www.vivek.4mg.com/javacertification/jsexam.htm
I have a problem understanding Super sup = new Sub();
If any class has a superclass then the superclass constructor will be called while creating an object. so in this case a super object will be created even if sub constructor is called.
sup.index will be 5 and
sup.printVal will print super
but the answer is
c) The code compiles and "5, Sub" is printed to standard output.
Can anyone please explain where i am wrong in my understanding.