Self-Review Exercises
14.1 State whethereach of the following is true or false. If false, explain why.
a) When String objects arecompared using ==, the result is true if the Strings contain thesame values. (False,String objects are compared using operator == to determine whether they’re the same object in memory.)
b) A String can bemodified after it’s created. (False,String objects are immutable and cannot be modified after they’re created.
StringBuilder objects can be modified after they’re created.)
14.2 For each ofthe following, write a single statement that performs the indicated task:
a) Compare the string in s1 to the stringin s2 for equality of contents. (s1.equals(s2))
b) Append the string s2 to the strings1, using +=. (s1+=s2)
c) Determine the length of the string in s1. (s1.length())