And the conclusion everyone found was that literals dont get garbage collected...Altho I was myself not very well convinced of the same... However I had accepted it.. But now this 2nd case (urs) has again made me think, if literals also get garbage collected!
Lets wait and see what everyone else has to say abt it!
The good new is, you're right. The answer should be 0. There are no objects eligible for Garbage Collection in that example. String literals are not eligible for garbage collection and, in that example, that's all you have.
The better new is that this is not on the SCJP exam. You'll have to answer questions about garbage collection, but you won't have to answer questions about Sting literals in terms of garbage collection.