• 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 exceptions

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are checked exceptions?
Could any explain me about this in details and also i would like to know if there are any sites to understand OOPs with java.
thanks in advance
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are checked exceptions?
A checked exception is any exception that is listed in the throws clause of a method and not an ancestor of RuntimeException. For example:

The compiler will complain on the call to test2() because IOException is a checked Exception, so you must wrap the call in a try-catch block:

Also take note of the fact that even though test1() is declared to throw RuntimeException, the compiler doesn't make any effort to enforce that as it does with the IOException. It is really a waste of time to declare a throws RuntimeException because the fact is any method can unexpectedly throw a RuntimeException.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic