• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference Between Checked&Un Checke Exceptions  RSS feed

 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checked exceptions which we can Handle Them By Using try,catch Block&&u8nchecked Exceptions are which we can Advertise them Using throws key word.

Any one tell me is this Right way Iam Thinking or Not
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Both checked and unchecked exceptions can be declared via "throws", and both can be handled by try/catch.

Unchecked exceptions (subclasses of RuntimeException) do not need to be declared by a "throws" clause or have a surrounding try/catch. In other words, the programmer can choose to ignore them if he wants (and suffer the consequences if they do occur).
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or to put it another way, checked exceptions are "checked" by the compiler to make sure that you've done something with them (either handled or declared).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!