• 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

may i know the difference between

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
we are saying exception is a runtime time error at the time of program execution.

May know the difference between checked exception and unchecked exception. ?

what are examples comes under checked exception and examples comes under unchecked excetion.?

thanking you
with regards
k.ramesh







thanking you sir,
k.ramesh
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Exceptions Tutorial
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked exceptions are checked at compile time and usually indicate syntax errors, missing libraries, and other structural problems.
Unchecked errors are thrown at runtime and typically indicate logic errors, like getting a null value when there should not be one.
Hence a NullPointerException would be thrown.
http://java.sun.com/docs/books/tutorial/essential/exceptions/runtime.html
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked exceptions are also thrown at runtime, of course. If an exception is checked that just means that any piece of the code that might throw a checked exception has either a throws in the methods signature or a try/catch around it. Take FileReader for example, the compiler does not check if the file exists(which would be pointless and impossible to check anyway), but makes sure that there is code in place to handle that possibility.

Given that, it is a mystery to me why NumberFormatException isn't checked. Anything that accepts input from an outside source(network, keyboard, file, ect) should be forced to check for error conditions, IMO. and methods that throw NumberFormatException might not directly take input from outside the program, but that is pretty much the only time they are called.
[ October 12, 2006: Message edited by: Robert Hill ]
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only the Error and RuntimeException and all of it's subclasses are unchecked exceptions. The NumberFormatException is subclassed from the RuntimeException and therfore it's an unchecked exception. Don't ask why the boys of Sun have put it in there. Also don't ask why NullPointerException is an unchecked exception

All subclasses of Exception, other than RuntimeException, are checked Exceptions. You indeed have to catch them in a try-catch-finally block, or if you don't want to catch them, you have to put it in the throws clause of the corresponding method.
[ October 12, 2006: Message edited by: Bauke Scholtz ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic