DEV Community

Jayashree
Jayashree

Posted on

what is Exception?

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
Enter fullscreen mode Exit fullscreen mode

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)