Thanks a lot for the replies but I am still a bit confused about the test method.
When we are inside the test method then once the exception is thrown for the first time then it was caught by the subsequent catch clause but what happens to the exception which was thrown within the catch clause? So after that finally has to be executed, so it again throws the exception which we catching in the main() method. So the output is
but again what happens to the exception which was thrown within the catch clause of test method. I thought it should be caught within the main method but indeed it is not. Can you guys explain me why is that?