JAVA
Exception handling
www.atozknowledge.com
atozknowledge.com@gmail.comwww.atozknowledge.com
Exception handling
▪ The exception handling is one of the powerful mechanism provided
in java. It provides the mechanism to handle the runtime errors so
that normal flow of the application can be maintained.
atozknowledge.com@gmail.comwww.atozknowledge.com
Error vs Exception
▪ Error
▪ Error is irrecoverable e.g. OutOfMemoryError,VirtualMachineError,
AssertionError etc.
▪ Exception
▪ Exception is recoverable for example ArithmeticException occurs
atozknowledge.com@gmail.comwww.atozknowledge.com
Blocks
▪ TRY
▪ Try that identifies the exception
▪ THROW
▪ Throw that throw the exception from try to catch
▪ CATCH
▪ Catch that handles the exception
atozknowledge.com@gmail.comwww.atozknowledge.com
Advance block
▪ FINALLY
▪ Forcible execution
▪ THROWS
▪ throws keyword gives a method flexibility of throwing an Exception
rather than handling it. with throws keyword in method
atozknowledge.com@gmail.comwww.atozknowledge.com

Java Exception handling

  • 1.
  • 2.
    Exception handling ▪ Theexception handling is one of the powerful mechanism provided in java. It provides the mechanism to handle the runtime errors so that normal flow of the application can be maintained. atozknowledge.com@gmail.comwww.atozknowledge.com
  • 3.
    Error vs Exception ▪Error ▪ Error is irrecoverable e.g. OutOfMemoryError,VirtualMachineError, AssertionError etc. ▪ Exception ▪ Exception is recoverable for example ArithmeticException occurs atozknowledge.com@gmail.comwww.atozknowledge.com
  • 4.
    Blocks ▪ TRY ▪ Trythat identifies the exception ▪ THROW ▪ Throw that throw the exception from try to catch ▪ CATCH ▪ Catch that handles the exception atozknowledge.com@gmail.comwww.atozknowledge.com
  • 5.
    Advance block ▪ FINALLY ▪Forcible execution ▪ THROWS ▪ throws keyword gives a method flexibility of throwing an Exception rather than handling it. with throws keyword in method atozknowledge.com@gmail.comwww.atozknowledge.com