Oracle
1Z0-804 · Question #141
Given: StringBuffer b = new StringBuffer("3"); System.out.print(5+4+b+2+1); What is the result?
The correct answer is F. Compilation fails. The code will not compile. The print function cannot handle the mixture of integers and strings. Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous
String Processing
Question
Given:
StringBuffer b = new StringBuffer("3"); System.out.print(5+4+b+2+1); What is the result?
Options
- A54321
- B9321
- C5433
- D933
- EOutput is Similar to: 9java.lang.StringBuffer@100490121.
- FCompilation fails.
How the community answered
(66 responses)- A2% (1)
- B2% (1)
- C12% (8)
- D5% (3)
- E3% (2)
- F77% (51)
Explanation
The code will not compile. The print function cannot handle the mixture of integers and strings. Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous
Topics
#StringBuffer#string concatenation#compilation error#operator overloading
Community Discussion
No community discussion yet for this question.