Multiple choice technology programming languages

What will be output from the following statements: System.out.println(1+2+"3"); System.out.println("1"+2+3);

  1. 33, 33

  2. 123, 33

  3. 33, 123

  4. 123, 123

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In the first statement, 1+2=3 is evaluated first (arithmetic before string concatenation), then concatenated with "3" to produce "33". In the second statement, "1"+2 produces "12" (string concatenation), then "12"+3 produces "123". String concatenation starts when a string is encountered.