What is the difference between checked and unchecked exception?

What is the difference between checked and unchecked exception?
[70 byte] By [atmaram.pradhana] at [2007-11-27 8:22:14]
# 1
One has more fashion sense.
cotton.ma at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...
# 2
and the other one probably plays golf four days a week for a living?
ejpa at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...
# 3

http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html

Here's a quick overview of exceptions:

The base class for all exceptions is Throwable. Java provides Exception and Error that extend Throwable. RuntimeException (and many others) extend Exception.

RuntimeException and its descendants, and Error and its descendants, are called unchecked exceptions. Everything else is a checked exception.

If your method, or any method it calls, can throw a checked exception, then your method must either catch that exception, or declare that your method throws that exception. This way, when I call your method, I know at compile time what can possibly go wrong and I can decide whether to handle it or just bubble it up to my caller. Catching a given exception also catches all that exception's descendants. Declaring that you throw a given exception means that you might throw that exception or any of its descendants.

Unchecked exceptions (RuntimeException, Error, and their descendants) are not subject to those restrictions. Any method can throw any unchecked exception at any time without declaring it. This is because unchecked exceptions are either the sign of a coding error (RuntimeException), which is totally preventable and should be fixed rather than handled by the code that encounters it, or a problem in the VM, which in general can not be predicted or handled.

jverda at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...
# 4
> One has more fashion sense.Ok then, Giorgio Armani, which is the more fashionable?
georgemca at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...
# 5
checked exception is more fashionable cause nobody has checked unchecked exception in his code so it has no fashion sense. Hence checked exception has more fashion sense then unchecked exception.
sachin.agrawala at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...
# 6

> checked exception is more fashionable

> cause nobody has checked unchecked exception in his

> code so it has no fashion sense. Hence checked

> exception has more fashion sense then unchecked

> exception.

That's a somewhat circular argument!

Because of the broken stylus, the album was ruined

Because the album was ruined, the stash wasn't rolled on it

Because the stash wasn't rolled, the pigs found it

Because the pigs took our stash, we got busted and fined

Because of the fine, we couldn't replace the stylus

Because of the broken stylus, the album was ruined...

georgemca at 2007-7-12 20:10:52 > top of Java-index,Core,Core APIs...