What is the difference between Checked and Unchecked
exception? Give some examples

Answers were Sorted based on User's Feedback



What is the difference between Checked and Unchecked exception? Give some examples..

Answer / narendra

checked Exceptions must be dealt with in either a try/catch
block or by
declaring a "throws" in a method. Unchecked exceptions
normally are
Runtime exceptions like NullPointerException or
ClassCastException.

A simple rule of thumb: If it's an exception you can
possibly deal with
(continue to run the program using some alternative code),
use checked
exceptions. For exceptions that should never happen (if they
do, it's a
bug), use unchecked (Runtime) exceptions which will come up
to the
surface and displayed to the user. Like this you assure that
if there's
a bug, it will show up eventually and can be fixed, and you
don't run
the risk of catching an exception and forgetting to deal
with it (f.i.
empty catch block).

Is This Answer Correct ?    4 Yes 1 No

What is the difference between Checked and Unchecked exception? Give some examples..

Answer / padmaja

1. Checked exceptions are exceptions that must be
declared in the throws clause of a method. A checked
exception indicates an expected problem that can occur
during normal system operation. Checked exceptions must be
2. Unchecked exceptions are exceptions that do not
need to be declared in a throws clause. An unchecked
exception indicates an unexpected problem that is probably
due to a bug in the code. The most common example is a
NullPointerException.They don't have to be caught or
declared thrown.
3. Checked exceptions in Java extend the
java.lang.Exception class. Unchecked exceptions extend the
java.lang.RuntimeException.

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More Core Java Interview Questions

What are the two ways in which thread can be created?

0 Answers  


What is difference between identifier and variable?

0 Answers  


write a program to create an vector with string(add,remove) operation.and value should be enter through keyboard.

0 Answers   Axcend,


What is charat java?

0 Answers  


What is the difference between Access Modifier and Access specifier?

1 Answers  






What is the loop in java?

0 Answers  


there are N number of matchboxes numbered 1...N.each matchbox contain various number of stick.Two player can alternatevely pick some amount of stick from the higest stick containing box . The player is condidered win if there is no stick after his move.Find the final move so that the move player win. Note:In case the number of stick is equal ,pick the stick from the higest numbered box.

0 Answers   Manhattan,


What is floating data type?

0 Answers  


What is a nested class?

0 Answers  


how many design pattern r there? and wht design pattern u use and why ?

5 Answers   HP,


How is string stored in java?

0 Answers  


What is the difference between throw and throws?

10 Answers   IBM,


Categories