nerdexam
Oracle

1Z0-851 · Question #61

Given: public class TestString1 { public static void main(String[] args) { String str = "420"; str += 42; System.out.print(str); } } What is the output?

The correct answer is D. 42042. See the full explanation below for the reasoning.

Question

Given: public class TestString1 { public static void main(String[] args) { String str = "420"; str += 42; System.out.print(str); } } What is the output?

Options

  • A42
  • B420
  • C462
  • D42042
  • ECompilation fails.
  • FAn exception is thrown at runtime.

How the community answered

(19 responses)
  • A
    5% (1)
  • D
    74% (14)
  • E
    5% (1)
  • F
    16% (3)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice