This question is from K&B book in the exam watch topic.
The below code won't compile. Here I will get unreported exception MyException; must be caught or declared to be thrown.
I dont understand what actually the code is telling. As I know doStuff() declaring the checked exception which is thrown by us and this method is not handling that exception
Am I right? If I am wrong please explain me what is going on in the program?
jayalakshmi charugundla wrote:
As I know doStuff() declaring the checked exception which is thrown by us and this method is not handling that exception
That is correct. 'someMethod' needs to explicitly handle the 'MyException' exception which is thrown by the 'doStuff' method.