So I've been reading both the Sierra/Bates book and Exam Cram 2 books.
There are two questions that are very similar that seem to me to give contradictory answers to one another.
The first one is from the Sierra/Bates book:
String x = new String("xyz");
y = "abc";
x = x + y;
The answer of how many String objects that were created is 4. This is from page 391 of the Sierra/Bates book.
On page 59 of the Brogden/Green book they have this code:
String A,B,C;
A = new String("1234");
B = A;
C = A + B;
Their answer to how many String objects that were created is 2.
So who is right? In the line of 'String x = new String("xyz")', Sierra/Bates argue that two objects are created. In the Brogden/Green book they argue that 'A = new String("1234")' only creates one object.
So who is right? Guess I'm confused now but I would think that Brogden/Green are right.
Anyone know the answer?
[ December 04, 2003: Message edited by: A. Fernandez ]
[ December 04, 2003: Message edited by: A. Fernandez ]