File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 17276

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 - iOS Apps
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"
I agree. Here's the link:
subject: Doubt in exception handling????
It's not a secret anymore!