I don't know exactly but, I guess when the object in the pool is not been pointed by any object it should be eligilble for the Garbage collection right. If not at one time or the other, the pool will bulge and the porcessing time will grow. am I right?
Garbage collection always takes place on the heap. Since none of the String instances above are on the heap, the no. of objects garbage collected is 0. [ September 06, 2006: Message edited by: Aniket Patil ]
SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Then they go on to show that the 1st example creates "abcdef" on the heap. figure 6.1
So it seems to me, by the K&B definition, that the answer to the original question is: 1 object is eligible for garbage collection.
Joined: Aug 07, 2006
I just re-read the link that Fred posted.
It appears that objects in the string pool are eligible for garbage collection, but not until the program is unloaded. So, for the exam, it seems to me it makes sense to think of all strings as objects that are eligible for GC if nothing references them. The specifics of the pool are not important for the exam.