This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 17233
    
    1

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Doubt in exception handling????
 
Similar Threads
Exceptions - Question
Exception Handling
Return from finally block
No Unreachable error ?
Crettaz's mock exam q46