Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unchecked and runtime exceptions in java [duplicate]

Tags:

java

exception

In Java, we have checked exceptions and unchecked exceptions. Also, we have runtime exceptions. My question is - Are all runtime exceptions unchecked exceptions and all unchecked exception are runime excepions? Means can these two words be used interchangeably?

like image 210
N.. Avatar asked Aug 09 '26 02:08

N..


1 Answers

All runtime exceptions (e.g. NullPointerException) are unchecked exceptions.

Since errors (e.g. StackOverflowError) are also unchecked exceptions, not all unchecked exceptions are runtime exceptions.

The Java Language Specifications define an unchecked exception: "The unchecked exception classes are the run-time exception classes and the error classes."

like image 158
emory Avatar answered Aug 11 '26 16:08

emory