ProgrammingHardWipro NLTH · Capgemini

What is printed?

What is printed?
String s = "a";
s.concat("b");
s += "c";
System.out.print(s);
  1. A. ac
  2. B. abc
  3. C. a
  4. D. ab

Correct answer: A. ac

Strings are immutable: concat's result was discarded, so only the += c took effect.

More OOP with C++ and Java questions

Exams that ask this topic