• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

checked Exception

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is checked Exception?How can we know what exception is checked or unchecked Exception?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Anmy",
Please check your private messages.
-Ben
 
reply
    Bookmark Topic Watch Topic
  • New Topic