• 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

Exception Handling

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends !

I have come across one typical point in Exception Handling saying that there are some Exceptions, those cause compile-time error if you do not declare them before throwing them,I would like to know what are the other cases which could be a probable cause for getting a compile-time error.

one is --IllegalAccessException that has to be declared before THROW,I do not know what else is/are. I would greatly appreciate if somebody knows about the whole idea of checked exception / unchecked exception and what needs to be handled and what could be an option ?

- thank you
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If an exception is "checked," that means the compiler requires you to either declare or handle the possibility of that exception being thrown.

All Exceptions are checked unless they are RuntimeExceptions (that is, a RuntimeException or any of its subclasses). All Errors are unchecked.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the checked exceptions need to be handled or declared.

e.g.

you need to place the above code inside the try block like:



Other Examples: java.io.IOException, java.lang.InterruptedException,
java.sql.SQLException etc.

Thanks,
 
chintan ramavat
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Marc and Chandra for making it clear and being help full.
 
Destroy anything that stands in your way. Except this 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