Narasimha
Regards,<br />Sandeep<br />(SCJP 1.4, SCBCD 1.3)
Narasimha
Originally posted by narasimha rao bandlamudi:
2. When you say, p1.anotherMethod() - anotherMethod() is non-static, hence it will be invoked from the run time type of the object, which is nothing but new Child(), hence anotherMethod() from the Child class will be invoked and the output is Child -- anotherMethod.
When you call aMethod() from anotherMethod() from Child class, actually it will be resolved to - this.aMethod(), and this will refer the object on which anotherMethod() is called which is nothing but new Child(), hence aMethod() of Child class will be invoked, hence the output, Child -- aMethod.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Originally posted by Bijesh Krishnadas:
the current object(this) will not be considered as the Parent object holding the Child reference, but as a genuine Child object...
Bijesh
Narasimha
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |