posted 18 years ago
Hi Gunjan,
Q05 overrides the call() method of its parent class Just.
When you create new object of subclass Q05, in its constructor super() is
automatically placed by the compiler.
OK now in the parent class method call() is called, and because the subclass
overrides the call() method, the subclass version of the call() method is called;
Real concern:
See the order of initialization in any book:
Until the parent class completes, member variables of the subclass get their
default value, (default means 0 to int, 0.0 to float, null to a reference variable and so on)
Second output is b=16, and that is explicit value because at this time,
subclass constructor call the call() method, and explicit value of the b is
printed (is has been initialized before the subclass constructor completes)
Please place the code in between tags.
Regards,
cmbhatt