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)