dear Ranchers,
I came across this question in one of the mocks.
Given this code, how many objects are eligible for GC at line 1
Now, 11
String objects are created and tmp holds reference to the last one.
The correct answer given is 10 objects eligible for GC, saying that even though tmp variable is out of scope, the local variable still has reference to it.
What I am thinking is at line 1, variable tmp is not available so there is no live reference that can access the object. So my answer is 11.
Anyone who can throw light on this.
Note: I don't know if this question is already being asked, because to me the search seems not much usable - it returns only posts dating to year 2001 and before for whatever reason.
thanks,
Roopesh.