This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes try catch block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "try catch block" Watch "try catch block" New topic
Author

try catch block

Chris Cleverley
Greenhorn

Joined: Mar 09, 2007
Posts: 22
Say there is a try block in which an exception is thrown. But the only exception that can be caught is one that is a parent of the exception that is actually thrown.
Will this exception be caught ?
Chris
KN
Ranch Hand

Joined: Aug 13, 2000
Posts: 66
Yes. Whenever you have a catch block which handles a particular exception, then all the exceptions which are the subclasses of that particular Exception are also caught with the same block.
 
Consider Paul's rocket mass heater.
 
subject: try catch block
 
Similar Threads
Exception Handling
Try Catch Finally - Voodoo Question
try-catch-final and throw new Exception cert question
Roundup question #132
Benefits of a try... finally only block