the two literals "abc" and "xyz" both cause an object to be created in the string pool. that's 2
then, whenever you do a "new String(<something>
", another String object is created. that's 3 total.
As you may know, Strings are immutable. you cannot change one once it is created. so, you "x=x+y" does not just append the 'y' string to the 'x' string. it creates a brand new string object, making 4 total.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors