what is difference between checked and unchecked exception
plz explain examples ?

Answer Posted / rakesh

A checked exception is one, which a block of code is likely
to throw, and represented by throws clause.It represents
invalid conditions in areas outside the immediate control of
the program (invalid user input, database problems, network
outages, absent files).
In Java it is expected that a method 'throws' an exception
which is a checked exception.They are subclasses of Exception.
While unchecked exceptions represent defects in the program
(often invalid arguments passed to a non-private method).
According to definition in The Java Programming Language, by
Gosling, Arnold, and Holmes,"Unchecked runtime exceptions
represent conditions that, generally speaking, reflect
errors in your program's logic and cannot be reasonably
recovered from at run time." They are subclasses of
RuntimeException, and are usually implemented using
IllegalArgumentException, NullPointerException, or
IllegalStateException
It is somewhat confusing, but note as well that
RuntimeException (unchecked) is itself a subclass of
Exception (checked)

Is This Answer Correct ?    31 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to generate bill in java swing?

682


What is jpanel swing?

560


What is jfc swing in java?

526


What is a component in swing?

505


What is swing control?

513






What is the difference between applications and applets?

595


What are the swing components in java?

505


What are the two key features of swing?

530


What are the containers available in swing?

526


What are the swing components?

502


How do you swing an applet?

614


Why would you use swingutilities.invokeandwait or swingutilities.invokelater?

554


Is java swing a framework?

566


In what context should the value of swing components be updated directly?

514


What is java swing components?

534