ExceptionHandling Part-1 in java
ExceptionHandling Part-1 in java
Handling in JAVA
Outline
2
◻ What is an Exception
◻ Types of Exceptions
◻ What is an Error
◻ Error vs Exception
◻ What is an Exception Handling
◻ Why we use Exception Handling
What is an Exception?
3
• Exceptions are recoverable using try, catch, throw, and throws keywords.
• Checked Exceptions
• Known to compiler at compile time.
• Must be either handled or specified using throws keyword.
• Examples: IOException, FileNotFoundException, etc.
• Unchecked Exceptions
• Not chekced at compile time.
• Known to the compiler at runtime, also called runtime Exceptions.
• Examples: ArithmeticException, ArrayIndexOutOfBoundException,
etc.
Checked Exception (Example)
6
• Errors are the conditions which cannot get recovered by any handling
techniques.
Error Exception
• java.lang.Object
All Java errors implement the java.lang.Throwable, or
• java.lang.Throwable
are extended from another inherited class therein. The
• java.lang.Exception
full hierarchy of error is:
• java.lang.RuntimeException
• java.lang.Object
• java.lang.ArithematicException
• java.lang.Throwable
• java.lang.NullPointerException
• java.lang.Error
• java.lang.VirtualMachineError
• java.lang.AssertionError
Thanks