Common Errors in Java

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.

A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors  are abnormal conditions that should never occur.

That is, Error and its subclasses are regarded as unchecked exceptions for the purposes of compile-time checking of exceptions.

Common Error Classes

  • AssertionError
  • ExceptionInInitializerError
  • StackOverflowError
  • OutOfMemoryError
  • NoClassDefFoundError

AssertionError

Thrown to indicate that an assertion has failed.

Common Errors in JavaScreen Shot 2020-04-17 at 10.08.35 PM

ExceptionInInitializerError

Signals that an unexpected exception has occurred in a static initializer.

Screen Shot 2020-04-17 at 10.11.22 PMScreen Shot 2020-04-17 at 10.11.31 PM

StackOverflowError

Thrown when a stack overflow occurs because an application recurses too deeply.

Screen Shot 2020-04-18 at 9.02.07 AMScreen Shot 2020-04-18 at 9.02.16 AM

OutOfMemoryError

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

Screen Shot 2020-04-18 at 10.18.35 AMScreen Shot 2020-04-18 at 10.19.00 AM

Full List of Error Classes

Screen Shot 2020-04-17 at 10.01.32 PMScreen Shot 2020-04-17 at 10.02.50 PM

Leave a Reply

Your email address will not be published. Required fields are marked *