• 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

Use of Checked and Unchecked Exception

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a query regarding Exceptions in Java, as there are 2 types of exceptions in Java - Checked and Unchecked exceptions, but in other languages viz C++ there is only Unchecked exception. Can someone help me whats the advantage in using Checked and Unchecked exceptions. Why not there is not only Checked exceptions or Unchecked exceptions in Java? Why java supports both Checked and Unchecked exceptions?

Regards
Naty
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think as java has the concept of checked exceptions , it gives the developers more flexibility.

In case of checked exceptions , the flow gets a chance to retry some action and make the program continue further.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes instead of leaving the decision to only the runtime environment, developer is also given a choice of how to and what to do further in case of any exception!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really an advanced question. Moving...
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked exceptions give the compiler the chance to, well, check to see if they're being handled. The folks who invented Java thought this would requiere developers to acknowledge exceptions and help avoid surprising errors at run time. Many Java users appreciate the compile time help, but some resent the extra coding required to catch or declare throwing checked exceptions.

Bruce Eckel's Thinking In Java (free online) has a good chapter on exceptions that mentions the question whether checked exceptions are good or not.
 
Naty wills
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all of you :-)

Regards
~Naty
 
reply
    Bookmark Topic Watch Topic
  • New Topic