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.
1 A String created with the new keyword will cause a new String object to be created. 2 A String reference created without the new keyword will not necessarily cause a new String object to be created 3 Once created, the value of a String object cannot be changed 4 The value of a String object can be changed using the setValue method. I think the 1,2,3 are true,but the answer is 1,2. what's the correct answer? [ December 03, 2002: Message edited by: Terry Kwan ]
Originally posted by Valentin Crettaz: 3 is wrong, String object are immutable, once created, there is no way to change any character of the string. All mutating methods you invoke on a String object will return you a new String object.
If a String object is immutable, then from the question, the option 3 is also correct.
It was wrong and now it is fixed, once created a String cannot be changed. Hmm perhaps I should have the ability to easily post a comment about the question... This was from question of the day system at www.examulator.com Marcus