nerdexam
Oracle

1Z0-804 · Question #34

Given: What is the result?

The correct answer is C. An exception is thrown at runtime. The code compile fine but java.lang.NullPointerException is thrown at runtime. x has no value. The code would run if line 2 was changed to:

Generics and Collections

Question

Given:

What is the result?

Options

  • A5
  • B6
  • CAn exception is thrown at runtime
  • DCompilation fails due to an error on line 6
  • ECompilation fails due to an error on line 7

How the community answered

(59 responses)
  • A
    12% (7)
  • B
    2% (1)
  • C
    75% (44)
  • D
    5% (3)
  • E
    7% (4)

Explanation

The code compile fine but java.lang.NullPointerException is thrown at runtime. x has no value. The code would run if line 2 was changed to:

Topics

#runtime exception#ClassCastException#generics type safety#unchecked cast

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice