1Z0-803 · Question #63
Given: Which approach ensures that the class can be compiled and run?
The correct answer is A. Put the throw new Exception() statement in the try block of try ?catch. We need to catch the exception in the doSomethingElse() method. private static void doSomeThingElse() { throw new Exception();} catch (Exception e) Note: One alternative, but not an option here, is the declare the exception in doSomeThingElse and catch it in the doSomeThing metho
Question
Given:
Which approach ensures that the class can be compiled and run?
Exhibit
Options
- APut the throw new Exception() statement in the try block of try ?catch
- BPut the doSomethingElse() method in the try block of a try ?catch
- CPut the doSomething() method in the try block of a try ?catch
- DPut the doSomething() method and the doSomethingElse() method in the try block of a try ?catch
How the community answered
(44 responses)- A82% (36)
- B2% (1)
- C7% (3)
- D9% (4)
Explanation
We need to catch the exception in the doSomethingElse() method. private static void doSomeThingElse() { throw new Exception();} catch (Exception e) Note: One alternative, but not an option here, is the declare the exception in doSomeThingElse and catch it in the doSomeThing method.
Topics
Community Discussion
No community discussion yet for this question.
