hi ganesh first i was confused with the answer being line 4 or 5 but now the answer is line 3. i did not get the point if two objects are pointing to the same thing does it mean they are elligible for garbage collection? how can this work please ellaborate and explain.
Actually object1 was pointing to say 'dhwani' in the next step it('dhwani') was made to point by object2.Now there are two object pointing the same right.So object1 will be eligible for garbage collection.Now you have got it i think.!!
I too was not very confident in the garbage collection.I saw this in the Headfirst book
well ganesh!! i understood that object 1 is elligible for GC at line 3 ,but as per i know about GC it is said till all the references of object are not "null" it is not elligible for GC,in the line 3 we assign the refernce of object1 to object2 now object 2 holds the reference of object1 ....so how come object1 is elligible for GC?i think you are getting what i meant to say.