Well, there are two objects - neither one is s, but one is currently referenced by s - that's the one which was created by the new operator. The other wass created in the intern string pool at class loading time, unless there was already a matching string in the pool at that time. So "two" seems like the best answer.
Yes, I should be more precise with differentiation between objects and their references. The trick is wherever in the code you use "test" or other literal it will be matched against global string pool and standard string literal handling technique applied to it.
Java Nut - the new String() constructor is taking another String as its parameter - where did this string come from? That's the string created from the literal "test", and it is created in the intern pool. It must exist before the new String() can be executed. So that's why there are two strings. Also - it's not only strings created with "new" which are not interned. Rather, it's only strings created from literals and constant expressions which are interned. Check out http://www.javaranch.com/ubb/Forum24/HTML/000530.html (5th message) where I explain this in more detail.
"I'm not back." - Bill Harding, Twister
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.