I have doubts that whether my concepts are clear in stringpool. Please study the following set of code and check if my answers are correct in number of objects created after the following set of statements:-
1)
String s1 = "abc";
String s2 = "def";
s2 + "xyz";
2)
String s1 = "abc";
String s2 = "def";
s2 = s2 + "xyz";
3)
String s1 = "abc";
String s2 = "def";
String s3 = s2 + "xyz";
4)
String s1 = "abc";
String s2 = "def";
s2 + "xyz";
String s3 = "defxyz";
As per what i know conceptually, in all the 4 cases above, there will be 4 objects created after the execution of each set of the lines.