What are unchecked exceptions in Java?

Java 8Object Oriented ProgrammingProgramming

An unchecked exception is the one which occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation. 

If you have declared an array of size 5 in your program, and trying to call the 6th element of the array then an ArrayIndexOutOfBoundsExceptionexception occurs.


Live Demo

public class Unchecked_Demo {
   public static void main(String args[]) {
      int num[] = {1, 2, 3, 4};


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
   at Exceptions.Unchecked_Demo.main(Unchecked_Demo.java:8)
Updated on 16-Jun-2020 12:45:47