Let's take a look step by step:
String s1 = "cat";
String s2 = "cat";
These two will be the same constant pool entry created in your class file by the javac compiler. When this class is loaded, this line (along with all the other lines of the constant pool) will be automatically interned, so it will also be merged with other lines "cat"in other classes.
String s3 = "c"+"at";
: , javac. , s1 s2. JLS, 15.18.1:
String (§12.5), (§15.28).
String s4 = new String("cat");
. Java , new , , . , ( , ), == , JIT- . == System.identityHashCode, , .
"cat", , , s1, s2 s3.
String s5 = "kitty"+"cat";
s3: javac "kittycat" . -, , .
String s6 = new String("kittycat");
s4: . s6 == "kittycat" , false.
String s7 = s5;
s5, .
, : 4 , 2 . : , (.. Java- ), .