Given: Which approach ensures that the class can be compiled and run?
A.
Put the doSomething() method in the try block of a try – catch
B.
Put the doSomething() method and the doSomethingElse() method in the try block of a
try – catch
C.
Put the doSomethingElse() method in the try block of a try – catch
D.
Put the throw new Exception() statement in the try block of try – catch
Explanation:
D
Answer: D
Explanation:
Options A, B, C are wrong because the exception is not propagated outside of the doSomethingElse() method.
The only solution in this case is D.