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

Exception Handling

chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
Hello friends !

I have come across one typical point in Exception Handling saying that there are some Exceptions, those cause compile-time error if you do not declare them before throwing them,I would like to know what are the other cases which could be a probable cause for getting a compile-time error.

one is --IllegalAccessException that has to be declared before THROW,I do not know what else is/are. I would greatly appreciate if somebody knows about the whole idea of checked exception / unchecked exception and what needs to be handled and what could be an option ?

- thank you
marc weber

Joined: Aug 31, 2004
Posts: 11343

If an exception is "checked," that means the compiler requires you to either declare or handle the possibility of that exception being thrown.

All Exceptions are checked unless they are RuntimeExceptions (that is, a RuntimeException or any of its subclasses). All Errors are unchecked.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
All the checked exceptions need to be handled or declared.


you need to place the above code inside the try block like:

Other Examples:, java.lang.InterruptedException,
java.sql.SQLException etc.


chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
Thank you Marc and Chandra for making it clear and being help full.
I agree. Here's the link:
subject: Exception Handling
It's not a secret anymore!