The replace method of the
String class will return the
same string if no replacement occurs. Otherwise a newly constructed String is returned.
So in the first question, "String".replace('T', 't') will evaluate to be the original "String". The ==
test is then true because of the rule that only one string literal is shared amongst all literals with the same contents.
The second question demonstrates that if a replacement occurs, new strings are constructed. These newly constructed strings will always be unique.