nerdexam
Oracle

1Z0-809 · Question #72

Given the code fragment: What is the result?

The correct answer is C. squarecircle. Option C is correct because the code uses System.out.print() (not println()) for both outputs, so "square" and "circle" are written to the same line with no separator, producing squarecircle. Option A (square...) would only be correct if execution stopped after the first print…

Question

Given the code fragment: What is the result?

Options

  • Asquare...
  • Bcircle...
  • Csquarecircle...
  • DCompilation fails.

How the community answered

(28 responses)
  • A
    7% (2)
  • B
    14% (4)
  • C
    75% (21)
  • D
    4% (1)

Explanation

Option C is correct because the code uses System.out.print() (not println()) for both outputs, so "square" and "circle" are written to the same line with no separator, producing squarecircle. Option A (square...) would only be correct if execution stopped after the first print or if the second print never ran - neither is the case here. Option B (circle...) would require the first print to be skipped entirely, which doesn't happen. Option D fails because the code is syntactically and semantically valid - there's no type mismatch, missing method, or other construct that would prevent compilation.

Memory tip: When you see print() without ln, picture the cursor staying glued to the end of the line - every subsequent print() stacks onto it. If you spot println(), that's the one that "flushes" to a new line.

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice