This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes checked Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "checked Exception" Watch "checked Exception" New topic
Author

checked Exception

kittu karan
Ranch Hand

Joined: Mar 09, 2008
Posts: 63
What is checked Exception?How can we know what exception is checked or unchecked Exception?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

A checked exception is an exception that you'll have to catch or rethrow, otherwise the compiler won't be happy. It's like saying that you're throwing eggs and there's nobody to catch them Checked exceptions extend the Exception class.
[ March 21, 2008: Message edited by: Christophe Verre ]

[My Blog]
All roads lead to JavaRanch
Jun Wu
Greenhorn

Joined: Mar 20, 2008
Posts: 14
Hi kiran peruka,the checked exception is a exception which you must try-catch or throws it,otherwise java compiler will angry! On the contrary ,you can try -catch unchecked exception ,or not,the complier doesn't complaint you !
Nikhil Raj
Greenhorn

Joined: Mar 20, 2008
Posts: 16
A checked exception is any exception that the compiler will check whether you are handling or not. If a code throws a checked exception, you should use a try catch block to catch it or add a throws clause to the method.
otherwise the compiler will report an error.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1761
    
    7

You can indeed determine whether an exception is a checked exception or an unchecked exception at compile-time, by waiting for the compiler to complain about the catch or specify requirement. If you don't have that luxury (e.g. on an SCJP exam), you can also determine this by looking at the exception's type hierarchy. Only subclasses of java.lang.Error and java.lang.RuntimeException are unchecked. Everything else is checked.
[ March 21, 2008: Message edited by: Jelle Klap ]

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Anmy",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: checked Exception