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

Which method of the Component class is used to set the position and size of a component?

570


How does accessibility works in swings?

555


What are the advantages of java swing over angular?

491


What is the function of internal frame in swing?

613


What is difference between jframe and swing?

518






Who created the swing?

503


How to move from one page to another in java swing?

623


Why are swing components called lightweight?

547


What are the two key features of swing?

536


What are the various components of swing?

515


When we should go for codebase in applet?

621


What is java awt and swing?

608


How to create a swing gui in java?

530


How to add calendar in java swing using eclipse?

779


Which types of components are used in designing swing based gui?

532