Exception
- The term Exception is shorthand for the phase "Exceptional event"(Unexcepted event).
- An Exception is an Event. Which occurs during the execution of a program that disrupt the normal flow of the programs instructions.
- Exceptions are done at runtime.
int a = 10;
int b = 0;
int c = a / b; // Exception occurs here
Output:
ArithmeticException: / by zero
Common Types of Exceptions
- ArithmeticException → divide by zero
- NullPointerException → accessing null object
- ArrayIndexOutOfBoundsException → invalid array index
- NumberFormatException → invalid number format
Top comments (0)