---
title: "Most common types of exception"  
description: "TOP TEN EXCEPTIONS On the basis of source who triggers exception, all exceptions are divided into two types: •	JVM Exception •	Programmatic Excepti"  
author: "Anonymous User"  
published: 2018-09-04  
updated: 2018-09-04  
canonical: https://www.mindstick.com/blog/11956/most-common-types-of-exception  
category: "java"  
tags: ["java"]  
reading_time: 4 minutes  

---

# Most common types of exception

## TOP TEN EXCEPTIONS

On the basis of source who triggers exception, all exceptions are divided into two types:

## • JVM Exception

## • Programmatic Exception

## JVM Exception:

The exception which are created by jvm automatically when an event occurs is [known as](https://answers.mindstick.com/qa/35703/ricky-ponting-is-also-known-as-what) JVM exception.

e.g. ArrayIndexOutOfBound exception

## Programmatic Exception:

The exception which are raised by either programmer or API developer is known as programmatic exception. e.g. IllegalArgument Exception.

## 1. ArrayIndexOutOfBound Exception:

It is a [child class](https://www.mindstick.com/forum/159389/how-to-remove-child-class-from-active-div) of runtime exception and hence it is unchecked.raised automatically by jvm whenever we are trying to access the array element with out of range index.

```
                    Int[] a =new int[10];
                    System.out.println(a[100]);
```

## 2. NullPointer Exception:

It is a child class of runtime exception and hence unchecked.it arises when we perform an action on null.e.g.

```
                   String s=null;
                   System.out.println(String.length());
```

**3. [StackOverFlowError](https://www.mindstick.com/forum/159247/stackoverflowerror-in-java-and-how-does-it-occur):**

It is a child class of error and hence unchecked.it arises whenever we are trying to perform recursive method invocation.e.g.

```
                              Class test{
                                      Public static void m1(){
                                                       m2();
                                                            }
                                      Public static void m2(){
                                                            m1();
                                                 }
                                      Public static void main(String[]args){
                                                       m1();
                                                                     }
```

**4. [NoClassDefFoundError](https://www.mindstick.com/forum/159433/java-noclassdeffounderror-identify-missing-class):**

It is a child class of error and hence unchecked.it arises whenever jvm unable to find the required class.e.g.

```
                        Java example
```

Example class is not present in the folder.

**5. [ClassCastException](https://www.mindstick.com/forum/159244/what-is-the-classcastexception-in-java-and-how-can-it-be-avoided):**

It is the child class of runtime exception and hence unchecked.it arises whenever are trying to typecast parent object to child type.e.g.

```
                 String s=new String(“aaa”);
                   Object o=(object) s;
                   Object o=new object();
                    String s=(String) o;
```

## 6. ExceptionInInitializerError:

It is the child class of runtime exception and hence unchecked.it arises while performing [initialization](https://www.mindstick.com/interview/160/what-is-the-difference-between-assignment-and-initialization) of [static variable](https://www.mindstick.com/forum/12657/static-variable-in-asp-dot-net) and while executing [static blocks](https://www.mindstick.com/interview/23344/is-it-possible-to-use-this-in-static-blocks).

## 7. IllegalArgumentException:

It is the child class of runtime exception and hence unchecked.it is raised explicitly by the programmer or by API developer to indicate that a method is invoked with invalid argument.e.g.

```
Thread t=new Thread();
t.setpriority(100);
```

**8. [NumberFormatException](https://www.mindstick.com/forum/159246/how-to-handle-the-numberformatexception-in-java):**

It is the child class of runtime exception and hence unchecked.it is raised by the programmer or API developer to indicate that we are trying to [convert string](https://www.mindstick.com/forum/157174/best-way-to-convert-string-to-bytes-in-python-with-example) to number type, but string is not formatted.e.g.

```
Int i=Integer.parseInt(“ten”);
```

## 9. IllegalStateException:

It is the child class of runtime exception and hence unchecked.it is raised by the programmer or API developer to indicate that a method is invoked in appropriate time.

## 10. AssertionError:

It is the child class of error and hence unchecked.it is raised by the programmer or API developer to indicate that assert statement fails.e.g.

```
                    Assert(false);
```

\

---

Original Source: https://www.mindstick.com/blog/11956/most-common-types-of-exception

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
