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.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in exception handling???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in exception handling????" Watch "Doubt in exception handling????" New topic

Doubt in exception handling????

Amit Das
Ranch Hand

Joined: Mar 05, 2005
Posts: 206
hi all,

plz help me by providing suitable reasoning for the behavoir exhibited by this code:

why does controll goes directly to 2) from 1)???

[ May 11, 2005: Message edited by: Mark Spritzler ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

1) First, your throw exception in the catch throws it up to the JVM and not to the try catch, so the catch of Exception will not be run.
2) Finally is always run. So after the catch of the InterruptedException, then it runs the finally code.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Amol Fuke
Ranch Hand

Joined: Apr 08, 2005
Posts: 129
Since its a exception of type InteruptedException it will be caught at line 1.Had the exception be of Exception other than InterruptedException then it will be caught in Exception clause.

"There are no mistakes, only lessons"
Have you checked out Aspose?
subject: Doubt in exception handling????
It's not a secret anymore!