What is the output of the following JAVA code? String s = "exam" + 9 + 9 + 9;
What is the output of the following JAVA code?
String s = "exam" + 9 + 9 + 9;
System.out.println(s);
Show answerHide answer
Correct answer: (D) exam: 999
Explanation
With a String on the left, each + is string concatenation: "exam" + 9 gives "exam9", and so on, giving "exam999". The 9s are not added to 27.