nerdexam
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)
  • A
    2% (1)
  • B
    2% (1)
  • C
    12% (8)
  • D
    5% (3)
  • E
    3% (2)
  • F
    77% (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.

Full 1Z0-804 Practice