i have a couple of doubts : 1)do method m1() has to use throws clause in its definition ...if not why ...since You are not using try,catch also.. 2) can we catch the runtime exceptions since indexArrayOutOfBoundsExcpetion is a runtime exception as well as NullPointerException.. 3)can anyone explain me the flow,since we have used return here do the finally block will be exceuted and also whether END will be printed .
Srikanth, The concept goes this way. You have to handle all Checked Exception either using try catch or using throws clause. "IndexOutOfBoundsException" is an Runtime exception and not checked exception, compiler wont complain that you haven't handled it but at run time your program will terminate if it's not handled.
A try clause should be accompanied either by a catch or finally class even both are ok. When an exception is throws the catch clause gets executed followed by th finally. the finally will be executed even if the exception is not thrown.