Given:
String s = new String(“3”);
System.out.print(1 + 2 + s + 4 + 5);
What is the result?
A.
12345
B.
3345
C.
1239
D.
339
E.
Compilation fails.
Explanation:
1 and 2 are added. Then the string s is concatenated.
Finally 3 and 4 are concatenated as strings.
B 3345
1+2 = 3
3+”3″=”33″
“33”+4+5= 3345
B is correct