Hello Sonir!
Compile the following code. It is yours, except that a throws-phrase is added to main.
It compiles fine and shows you, that answers 1)-3) are wrong. The things described in the 3 options are in the code as before, and are generally legal.
Without the throws, the main-method could throw an MyException (position marked with // (1)), that is not handled in the method body via try/catch, and not declared in the header of the method (throws ....). Because MyException is a subclass of Exception, this is not legal, and that is what the compiler says:
TestClass.java:13: unreported exception MyException; must be caught or declared to be thrown
tc.m1();
So answer 4) is correct.
See any
Java Book, Chapter Exception Handling, for further details,
Stefan
[ January 11, 2002: Message edited by: Stefan Zoerner ]