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 Eeceptions 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 "Eeceptions" Watch "Eeceptions" New topic


amrit singh
Ranch Hand

Joined: Nov 03, 2000
Posts: 42
Hi all !!!
when catching multiple exception the class hierarchy of exception is imortant i mean more specific must come b4
is this also true when we declare in throws statement
steve richardson

Joined: Dec 16, 2000
Posts: 3
No, when a method is declared to throw a number of Exceptions, there is no requirement to list these in any particular order of precedence. Generally though, you should try and throw as specifically as you can to help the client programmer and make the code cleaner and easier to read. On the other hand, though, if you have a method that throws five different exceptions that are all, say, sub-classes of IOException, it is better to simply say throws IOException, and then to catch the specific sub-classes in the calling code. Hope this is of some use.
I agree. Here's the link:
subject: Eeceptions
It's not a secret anymore!