When tmp goes out of scope, the object it references is no longer accessible to any live
thread, so the object becomes eligible for garbage collection right away when the loop ends. Therefore, I agree with Sergei that the correct answer is 11. The whizlabs explanation
Answer D is wrong because even though the tmp variable is out of scope in line 8, the local variable still has a reference
makes me ask, "What local variable? The tmp local variable that has gone out of scope and is unreachable by any live thread?" If that's the variable they mean, then this criteria for determining when an object becomes eligible for garbage collection runs counter to the explanation in K&B p. 432 which reads
we can now say with stunning clarity and resolve that, an object is eligible for garbage collection when no live thread can access it.
I've checked the
K&B errata page and found no alterations made to their claim. As far as I know, when a variable goes out of scope, it is no longer reachable by a live thread, and is therefore immediately made eligible for garbage collection.