This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Since you are properly handling the exception in main() by using try and catch block..
You need not to declare them in main using throws keyword..
Joined: May 08, 2007
hi!! Khushhal Thank you for your explanation,i got the point.
Joined: Mar 22, 2007
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?
Joined: Feb 07, 2005
Originally posted by Bharat Makwana: Hi Keith,
Exception is propagated to main method.The exception which is thrown by finally block in test() method is passed to main method. see following code
Output is B_B C
Oops. Sorry. You're right. I didn't read it close enough.