Howdy, Arif!
Welcome to the
Java Ranch!
Hope you enjoy it.
For the others: some notes about garbage collection:
First, regard that only
objects are garbage collected. Sometimes beginners tend to try to garbage collect variables.
Second main thing: an object is eligible for garbage collection when no live
thread can access it.
As in Arif's example: no other variable refers the first object, so it is useless. The object is still in memory, but nobody can use it. It can be GCd.
Citing myself:
is eligible for garbage collection
Means, that the garbage collector
may dump the object. You cannot do it by hand, as garbage collection works automatically in background in a daemon thread.
You cannot force it, but you can kind of persuade it to do it's job.
Therefore in all this questions, it says "is eligible for gc". When an answer to a question is "
is garbage collected" then it the answer is possibly false, as you cannot tell, when the thing is dumped actually.
For "island of isolation" follow the hint from Arif and search for it.
Yours,
Bu.