• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic