Saturday, July 14, 2012

Exception Hierarchy and Types of Exceptions

<<Previous                                                                Next>>
Throwable acts as a root for the entire Exception hierarchy.  This class contains the following two child classes.
  1. Exception: - These are removable and mostly caused by our program.
  2. Error: - These are non-recoverable and mostly caused due to lack of system resources.  






Checked Vs. Unchecked Exceptions: -

Checked Exceptions:-
                 The exceptions which are checked by the compiler for smooth execution of program at runtime are called checked Exceptions.
Example: InterruptedException, FileNotFoundException.
Unchecked Exceptions:-
                    The exceptions which are not checked by the compiler are called unchecked exceptions.
Example:  ArithmeticException, NullPointerException, BompBlastException.
  1. Whether the exception is checked or unchecked, compulsory it should be occurs at run time only.  There is no chance of occurring at compile time.
  2. RuntimeException and its child classes, Errors and its child classes are unchecked and all the remaining are considered as Checked Exceptions.

Fully checked Vs. Partially Checked Exceptions: -

A checked Exception is said be fully checked if and only if, its entire child classes also checked, otherwise that checked exception is called partially checked exception.
Example:
                    Exception    --------   Partially checked
                    IOException -----       Fully checked
                    ArithmeticException ------- Unchecked Exception.

1 comment:

  1. Good. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also virtual edge and Best Ways to Boost Digital Marketing for Your Virtual Event

    ReplyDelete