Can anybody explain me how there are 4 objects created? I know 3.
3. Given the following,
13.
String x = new String("xyz");
14. y = "abc";
15. x = x + y;
how many String objects have been created?
A. 2
B. 3
C. 4
D. 5
Ans--C. Line 13 creates two, one referred to by x and the lost String “xyz”. Line 14 creates one
(for a total of three). Line 15 creates one more (for a total of four), the concatenated String
referred to by x with a value of “xyzabc”.
A, B, and D are incorrect based on the logic described above.