• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
chintan ramavat
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • 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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • 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.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you Marc and Chandra for making it clear and being help full.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic