0 votes
in Java by

What is the difference between checked and unchecked exceptions in java or checked vs unchecked exception in java or checked/compile time exception vs unchecked/run time exception.

1 Answer

0 votes
by (4.4k points)

The main difference between checked and unchecked exception is that the checked exceptions are checked at compile-time while unchecked exceptions are checked at runtime.

Checked Exceptions:- Exceptions that checked at compile time that are called checked exceptions. As per Exception hierarchy all classes that extends Exception class except UncheckedException comes under checked exception.

There are following checked Exception:-  

  • Exception
  • IOException
  • EOFException
  • FileNotFoundExceptio
  • ParseException
  • ClassNotFoundException
  • CloneNotSupportedException
  • InstantiationException
  • InterruptedException
  • NoSuchMethodException
  • NoSuchFieldException

UnChecked Exceptions:- Exceptions that are not checked at the compile time that are called unchecked exceptions. Classes that extends RuntimeException comes under unchecked exceptions.

There are following Unchecked Exception:-

  • ArrayStoreException
  • IllegalArgumentException
  • IllegalMonitorStateException
  • IllegalPathStateException
  • IllegalStateException
  • NullPointerException
  • NoSuchElementException
  • BufferOverflowException
  • BufferUnderflowException
  • CannotRedoException
  • CannotUndoException
  • ClassCastException
  • CMMException
  • ConcurrentModificationException
  • DOMException
  • EmptyStackException
  • ImagingOpException
  • IndexOutOfBoundsException
  • MissingResourceException
  • NegativeArraySizeException

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.