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)- A12% (7)
- B2% (1)
- C75% (44)
- D5% (3)
- E7% (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.