• 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

Exception

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am confused at the checked/unchecked Exception.
How can I know which one is the checked Exception
need to catch in the program, and which one is
the unchecked Exception needn't to catch in the
program.
thanks
Krussi
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked exceptions are any classes that extend the exception class, excluding the class RuntimeException. RuntimeException and its descendents make up the set of unchecked exceptions. Note that the class Exception, itself, is an unchecked exception.
I hope that helps,
Corey
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Corey has explained checked and unchecked exceptions are based on the fact what exception class do they extend. SO to figure out whether to catch an exception in program or not you have to traverse the hierarchy to see if its an RunTime Exception or is in subtree of exception class (not under checked exception subtree - user defined exception).
You will have to refer to documentation to find out about pre-defined exceptions and further the API documentation should indicate about the exceptions the API throws.
hope that was helpful
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't forget the java.lang.Error Class -- it's decendents are also not checked.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jessica Sant:
Don't forget the java.lang.Error Class -- it's decendents are also not checked.


But don't get errors confused with exceptions. The class Error and Exception are siblings. Errors are not exceptions and vice versa. Each class extends Throwable.
But, like Jessica said, Errors are unchecked.
Corey
 
krussi rong
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks very much!
Krussi
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic