Oracle
1Z0-803 · Question #168
An unchecked exception occurs in a method doSomething(). Must other code be added in the doSomething() method for it to compile and run successfully?
The correct answer is D. No other code needs to be added.. According to Oracle, the Java programming language does not require methods to catch or to specify unchecked exceptions (RuntimeException, Error, and their subclasses).
Handling Exceptions
Question
An unchecked exception occurs in a method doSomething(). Must other code be added in the doSomething() method for it to compile and run successfully?
Options
- AThe exception must be caught.
- BThe exception must be declared to be thrown.
- CThe exception must be caught or declared to be thrown.
- DNo other code needs to be added.
How the community answered
(47 responses)- A2% (1)
- C4% (2)
- D94% (44)
Explanation
According to Oracle, the Java programming language does not require methods to catch or to specify unchecked exceptions (RuntimeException, Error, and their subclasses).
Topics
#unchecked exceptions#exception handling#RuntimeException
Community Discussion
No community discussion yet for this question.