What is exception

In Java an exception is an abnormal condition that occurs at run time. Also we can say it is an
event that disrupts or break the normal flow of program.Below are few most common Java exceptions classes.

In programming language, exception can occur due to many reasons. For example:

  • Trying to open a file that can not be found.
  • Entering invalid data.
  • Passing incorrect argument in the method or accessing element with an out of bound exception.

The main benefit of exception handling is to maintain the normal flow of the program or application.

In Java programming language, exceptions are objects basically. We can not throw any object as an exception, however only those objects whose classes descends from Throwable class. We can throw objects of our own design customized exception classes. To create your own class of throwable objects, you need only declare it as a subclass of some member of Throwable.