Top 10 Exception in Java

checked and unchecked exceptions is that checked exceptions are forced by compiler and used to indicate exceptional conditions that are out of the control of the program (for example, I/O errors), while unchecked exceptions are occurred during runtime and used to indicate ...

1-ArrayIndexOutOfBoundsException

2- NullPointerException

  • it is child class of RuntimeException it is unchecked Exception.
  • it is automatically raised by JVM .
  • when ever we are trying to perform any opration on Null

3-StackOverFlowError

  • it is a child class of error and it is unchecked .
  • When you recursly method invocation then you will get StackOverFlowError .

4- NoClassDefFoundError

  • when Java Virtual Machine is not able to find a particular class at runtime
  • it is a child class of error and it is unchecked .
  • it is automatically raised by JVM .

5-ClassCastException

  • It is child class of RuntimeException it is unchecked Exception.
  • It is automatically raised by JVM .
  • When ever we are trying to typecast parent to child type.

6- ExceptionInInitializerError

  • if any exception occurs while performing initilazation for static variable and while executing static blocks
  • It is automatically raised by JVM .

public class ArraysDS {
static {
String x = null;
System.out.println(x.length());}
public static void main(String[] args) {}}

7-IllegalArgumentException

  • This exception indicates that a method is called with incorrect input arguments.
  • Raised explicitly by programmer or by API developer

8- NumberFormatException

  • when you try to convert String to Number type but String is properly formatted.
  • Raised explicitly by programmer or by API developer

9 -IllegalStateException

  • Raised explicitly by programmer or by API developer
  • Once session expire we can’t call any method on that object otherwise we will get IllegalStateException.

10 -AssertionError

  • it is a child class of error ,hence it is unchecked.
  • Raised explicitly by programmer or by API developer.
  • when you assert statement is fail then you will get AssertionError.

Java||Spring-Boot|| Micro services Application developer|| INDIA

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS Deployment and Provisioning Tips

The curious case of graphql errors

Creating a game over screen in my space shooter

CS373 Spring 2022: Abinith Thallam Week 5

Prometheus API Client in Python

Top tools that will navigate you in your Startup: Been there, know that, ready to help

Masters of Organisation

8-Service UltaHost provides and their Fees

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sanjay Singh

Sanjay Singh

Java||Spring-Boot|| Micro services Application developer|| INDIA

More from Medium

Exception Handling in Java.!!!

Java Beginner’s Guide: What it is and why you should learn this programming language

Creating Strings in Java

JAVA /Interface