wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions 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 "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

Jugal Parikh
Greenhorn

Joined: Sep 09, 2008
Posts: 12
hello all,

could you tell me the difference between checked exceptions and unchecked exceptions with some examples.i am getting a bit confused between the two.
thank you.
Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Check this
Jugal Parikh
Greenhorn

Joined: Sep 09, 2008
Posts: 12
thanks pranav but, that did'nt really clear my doubt.
the link you posted had difference between compile time and runtime errors.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Originally posted by Jugal Parikh:
hello all,

could you tell me the difference between checked exceptions and unchecked exceptions with some examples.i am getting a bit confused between the two.
thank you.



Checked Exceptions are the those Exceptions which the compiler forces you to declared or catch it.
If you dont you ll get a compiler error.
Example of this IOException and all Subclasses of Exception excluding Runtime Exceptions.

Unchecked Exceptions are those Exceptioons which are not required to be caught or handled.
All sublclasses of RuntimeException are unchecked Exceptions like
ClassCastException ,ArrayIndexOutOFBounds,NullPointerException , etc.

Ther is no harm if you declare or handle the exception, though its better not to ,
But you will not get a compiler error for not declaring or handling such Exceptions.

Hope it is clear.


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Jugal Parikh
Greenhorn

Joined: Sep 09, 2008
Posts: 12
yup it is.thanks Nabila
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions
 
Similar Threads
compile time exception vs runtime exception
Difference between Declarative and Programmatic Exception in struts
Dan's question
about Exception Handling
TelnetProtocolException