Home » java » Types of Exceptions

Types of Exceptions

In java programming, Exception class is a subclass of class Throwable.

Apart from Exception class, class Error is also derived from class Throwable.

Error: In java programming, error is Unrecoverable. It occurs during compile time.

For example, if we write wrong syntax then error will generate during compile time.

There are two types of Exception

  1. Checked Exception
  2. Unchecked Exception

Checked Exception

Here is the list of some checked exception

  1. IllegalAccessException: in java programming, this exception occurs when access to a class is denied.
  2. ClassNotFoundException: this exception occurs when class not found.
  3. NoSuchMethodException : when a requested method dose not exist this exception occurs.
  4. CloneNotSupportedException: in java programming,If you are trying to use the clone method in a classwhere Cloneable interface is not implemented, it throwsCloneNotSupportedException. Clone() method is used to create exactcopy of a object
  5. InterruptedException : in java, when we work with multiple threads then one thread  interrupts another thread.  
Exception Hierarchy

Unchecked Exception

  1. ArithmeticException : in java programming this exception, represent the arithmetic error, such as divided-by-zero.
  2. IndexOutOfBoundsException: when some type of index is out of bounds this exception occur.
    • ArrayIndexOutOfBoundsException: in java programming this exception represent the Array index is out of bound. This condition is arises when we try to access illegal array index.
    • StringIndexOutOfBoundsException : in java programming, when we access the index outside the bound of string than this exception occurs.
  3. NegativeArraySizeException: when array is created with negative size than this exception is arises.
  4. NullPointerException: in java programming this exception occurs when invalid use of null reference.
  5. IllegalThreadStateException: this exception occurs , when required operation not compatible with current thread state.
Managed by MochaHost - Fast & Easy WordPress Hosting