I\'m reviewing a midterm I did in preparation for my final exam tomorrow morning. I got this question wrong, but there\'s no correct answer pointed out, and I neglected to a
main()
ultimately throws all unhandled exceptions, right? So, effectively adding throws FileNotFoundException
is redundant.
A throws
statement implies nothing about how a method handles an exception. This main()
method may indeed handle FileNotFoundException
, and then re-throw it.
So, that throws
statement indicates nothing about how any exception is caught and handled. And questions 3 & 4 are only valid if we assume that the exception in question it not handled. Without that assumption, the questions are indeterminate. With that assumption, both 3 & 4 are true!
The correct answer is to ask the school for a refund for this class - even 6.5 years later.
Could you please forward this teacher's contact information? I would like to have a word with them.
Dude, a little late, but answer is Number 3.
Number 1 is false because it is not handling FileNotFoundException
Number 2 is false for the same reason.
Number 3 is true. If a FileNotFoundException is thrown, the main method will terminate.
Number 4 is false. It would not terminate in case of ANY exception. It would terminate only in case of unchecked exception or FileNotFoundException. If there are not other checked exceptions declared in the 'throws' clause, it means they are being handled within the method.