shashank dwivedi wrote:
shashank dwivedi wrote:
James Boswell wrote:shashank
Why don't you tell us what you think the answer is?
well i think it should be 2.The reason why i think this is because i have created objects of child class
which should call constructor of its parent class.
One object dies here should mean two objects eligible for garbage collection.
I am not sure though if i am right..
please help!
And ofcourse i am talking after line 19.
IMO, I guess it depends on what you mean by "after line 19". If you mean, exactly after execution, and the "b1" local variable is still in scope, then one object is eligible for GC. If you mean, the next line of code, where the main() method completes, and the "b1" and "b2" variable are no longer in scope, then two objects are eligible for GC.
Henry