File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception Handling" Watch "Exception Handling" New topic
Author

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
Sheriff

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
sscce.org
Chandra Bhatt
Ranch Hand

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

e.g.

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



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

Thanks,


cmbhatt
chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
Thank you Marc and Chandra for making it clear and being help full.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception Handling