This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
These type of questions are asked so many times here, just try searching a bit you wil find so many threads. All the String literals (if it was not met before in the code), concatenation,toUpperCase() etc.. will create a new object but toString() will not.
This type of question creates a lot of confusion for people who refer to K&B. It misses the statement that string literals are created when the class is loaded. Well that's how its 3.....seems tricky. and toString doesn't create a new object because that is already there in the pool.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api