Oracle
1Z0-804 · Question #136
Given: String s = new String("3"); System.out.print(1 + 2 + s + 4 + 5); What is the result?
The correct answer is B. 3345. 1 and 2 are added. Then the string s is concatenated. Finally 3 and 4 are concatenated as strings.
String Processing
Question
Given:
String s = new String("3"); System.out.print(1 + 2 + s + 4 + 5); What is the result?
Options
- A12345
- B3345
- C1239
- D339
- ECompilation fails.
How the community answered
(53 responses)- A2% (1)
- B81% (43)
- C2% (1)
- D9% (5)
- E6% (3)
Explanation
1 and 2 are added. Then the string s is concatenated. Finally 3 and 4 are concatenated as strings.
Topics
#string concatenation#operator precedence#type conversion#numeric literals
Community Discussion
No community discussion yet for this question.