String s's reference is returned by methodA() and assigned to a. a is visible throughout main() and not eligible for collection. when methodA() return, String t is absolutely useless, so during the execution of the lines after line 4 in main(), t is eligible for collection.
a is visible throughout main() and not eligible for collection.
when methodA() return, String t is absolutely useless, so during the execution of the lines after line 4 in main(), t is eligible for collection.