posted 19 years ago
Answer : 1
Explanation :
Exception :java.lang.IllegalAccessExcption must be caught or placed in the throws clause of the throwMethod(), i.e. the declaration of throwMethod() bechanged to "static void throwMethod() throws IllegalAccessExcption". Thus compilation error will occur.
My question:
In the main method, throwMethod() is called; there is a catch block for catching this.
Then, why do we need the thros clause, as specified in the explanation?
Can't the exception thrown by the call to throwMethod() be handled by the catch block in the main() method itself?