Java Exceptions are divided in two categories RuntimeException also known
as unchecked
Exception and checked Exception. Main
difference between RuntimeException and checked Exception is that, It is
mandatory to provide try catch or try
finally block to handle checked Exception and failure to do so will result
in compile time error, while in case of RuntimeException this is
not mandatory. Difference between checked and unchecked exception is one of the
most popular question on Java interview
for 2 to years experienced developer especially related to Exception
concepts. Answer to this question is rather similar as mentioned in previous
lines and they are mostly asked along with other Java Exception interview
questions like difference
between throw and throws and Error
vs Exception. Any Exception which is subclass of RuntimeException are called
unchecked and mandatory exception handling is not requirement for them. Some of
the most common Exception like NullPointerException,
ArrayIndexOutOfBoundException are unchecked and they
are descended from java.lang.RuntimeException. Popular
example of checked Exceptions are ClassNotFoundException
and IOException and that's the reason you need to provide a try
catch finally block while performing file operations in Java as many of them
throws IOException. Similarly many utilities of
Reflection API throws java.lang.ClassNotFoundException. In this
Java tutorial we will see some more difference between RuntimeException and
checked Exception in Java.