aspose file tools*
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
Author

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)???

thanx,
amit
[ May 11, 2005: Message edited by: Mark Spritzler ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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.

Mark


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"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in exception handling????