What will the following program print when run?.
public class Main { public static void main(String[] args) { String str1 = "lower", str2 = "LOWER", str3 = "UPPER"; str1.toUpperCase(); str1.replace("LOWER","UPPER"); System.out.println((str1.equals(str2)) + " " + (str1.equals(str3))); } }
Select the one correct answer.
(b)
The reference value in the reference str1 never changes and it refers to the string literal "lower" all the time.
The calls to toUpperCase()
and replace()
return a new String object whose reference value is ignored.