Meaningless Drivel is fun!
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
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: try catch block
 
It's not a secret anymore!