• 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

exceptions

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone plz tell me what exactly is a checked exception and how is it different from an unchecked exception
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at here:
http://www.javapractices.com/Topic129.cjp
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nivi,

Checked exceptions are actually checked by the compiler.These are conditions which need to be dealt with compulsarily by the part of the code implementing these conditions.

For example, if a method is using some File Operation then it needs either to deal with the exception directly or pass these exceptions to the caller method.

Unchecked exceptions are genuine defects or logical errors in the code.They are not checked at compile time but at runtime. eg ArthmeticException,ArrayIndexOutOfBoundsException.

Hope the explaination helps.

Nikhil
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi nivi

in java checked exceptions are exceptions which must be handled by either the method throwing the exception or by its calling method or if the current method has ducked the exception by declaring it then the caller method has to handle(or catch )it.
all exceptions except RuntimeExceptions in java are checked exceptions.
there is no need to declare the unchecked exceptions.but they still need to be handled somewhere down the call stack.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Unchecked exceptions are the subclasses of RuntimeException.

Runtime exceptions represent problems that are the result of a programming problem or the bugs in our program. RuntimeExceptions are exceptions that occur within the JVM during runtime. Thus,the compiler does not require that you catch or specify runtime exceptions (although you can).

Compile time exceptions (Checked Exceptions)are exceptions that occur in code outside of the Java runtime system.The compiler ensures that nonruntime exceptions are caught or specified.

Ashok
 
nivi zal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot to all of u for helping me understand this!
 
Don't count your weasels before they've popped. And now for a mulberry bush related 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