How many String objects are created by the following code?
String x = new String(\"xyz\");
String y = \"abc\";
x = x + y;
I have visited ma
1.objects created in heap area "xyz" //created by 'String x' and xyzabc //created by 'x+y'(concatenation)
2.objects created in scp(string constant pool) "xyz" //created for future purpose which is not available for garbage collection and "abc" //created by 'String y' literal
so total objects created in this case is 4