$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · easy · #241

What is the output?

String s = "ab";
s.toUpperCase();
System.out.println(s);
  1. AB
  2. Ab
  3. null
  4. ab
Strings are immutable: toUpperCase returns a new string, and the result is thrown away, so s is still "ab".
Play Problem Solving ▸