• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Exception Concepts

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Due to some problem at javaranch site I was unable
to see the reply for my post so I am posting my question again
Please answer.
What are the checked exceptions ?
How these are different from run time exceptions ?
Please explain them in detail and also give examples of
both type of exceptions ?
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked exceptions are those which are checked by the compiler for proper exception handling. ie., the code that throws a checked exception must be enclosed in a try-catch-finally block and/or itself must be declared in the throws clause. All exceptions that are subclass of java.lang.Exception but are not subclass of java.lang.RuntimeException are checked exceptions. Examples include IOException, AWTException, SQLException etc.
Runtime exceptions are subclasses of java.lang.RuntimeException and they are also called unchecked exceptions. It is not required to either declare them in the throws clause or enclose the throwing code in the try-catch-finally block. java.lang.Error and its subclasses are also unchecked throwables. Usually these indicate unrecoverable error conditions in the program and hence you don't really benefit from catching them. Examples include ArithmeticException, ClassCastException, IndexOutOfBoundsException, VirtualMachineError etc.
I suggest you go through the API documentation for more information. Also read JLS Section 11 Exceptions that has a very detailed description about checked and unchecked exceptions.
Hope that helps!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic