Many people say that checked exceptions (i.e. these that you should explicitly catch or rethrow) should not be used at all. They were eliminated in C# for example, and most languages don't have them. So you can always throw a subclass of RuntimeException (unchecked exception).

However, I think checked exceptions are useful - they are used when you want to force the user of your API to think how to handle the exceptional situation (if it is recoverable). It's just that checked exceptions are overused in the Java platform, which makes people hate them.

Here's my extended view on the topic.

As for the particular questions:

  1. Is the NumberFormatException considered a checked exception?
    No. NumberFormatException is unchecked (= is subclass of RuntimeException). Why? I don't know. (but there should have been a method isValidInteger(..))

  2. Is RuntimeException an unchecked exception?
    Yes, exactly.

  3. What should I do here?
    It depends on where this code is and what you want to happen. If it is in the UI layer - catch it and show a warning; if it's in the service layer - don't catch it at all - let it bubble. Just don't swallow the exception. If an exception occurs, in most of the cases, you should choose one of these:

  • log it and return
  • rethrow it (declare it to be thrown by the method)
  • construct a new exception by passing the current one in constructor
  1. Now, couldn't the above code also be a checked exception? I can try to recover the situation like this? Can I?
    It could've been. But nothing stops you from catching the unchecked exception as well.

  2. Why do people add class Exception in the throws clause?
    Most often because people are lazy to consider what to catch and what to rethrow. Throwing Exception is a bad practice and should be avoided.

Alas, there is no single rule to let you determine when to catch, when to rethrow, when to use checked and when to use unchecked exceptions. I agree this causes much confusion and a lot of bad code. The general principle is stated by Bloch (you quoted a part of it). And the general principle is to rethrow an exception to the layer where you can handle it.

Answer from Bozho on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-checked-vs-unchecked-exceptions
Java Checked vs Unchecked Exceptions - GeeksforGeeks
June 2, 2026 - Fully Checked Exception: A checked exception where all its child classes are also checked (e.g., IOException, InterruptedException). Partially Checked Exception: A checked exception where some of its child classes are unchecked (e.g., Exception).
Top answer
1 of 16
526

Many people say that checked exceptions (i.e. these that you should explicitly catch or rethrow) should not be used at all. They were eliminated in C# for example, and most languages don't have them. So you can always throw a subclass of RuntimeException (unchecked exception).

However, I think checked exceptions are useful - they are used when you want to force the user of your API to think how to handle the exceptional situation (if it is recoverable). It's just that checked exceptions are overused in the Java platform, which makes people hate them.

Here's my extended view on the topic.

As for the particular questions:

  1. Is the NumberFormatException considered a checked exception?
    No. NumberFormatException is unchecked (= is subclass of RuntimeException). Why? I don't know. (but there should have been a method isValidInteger(..))

  2. Is RuntimeException an unchecked exception?
    Yes, exactly.

  3. What should I do here?
    It depends on where this code is and what you want to happen. If it is in the UI layer - catch it and show a warning; if it's in the service layer - don't catch it at all - let it bubble. Just don't swallow the exception. If an exception occurs, in most of the cases, you should choose one of these:

  • log it and return
  • rethrow it (declare it to be thrown by the method)
  • construct a new exception by passing the current one in constructor
  1. Now, couldn't the above code also be a checked exception? I can try to recover the situation like this? Can I?
    It could've been. But nothing stops you from catching the unchecked exception as well.

  2. Why do people add class Exception in the throws clause?
    Most often because people are lazy to consider what to catch and what to rethrow. Throwing Exception is a bad practice and should be avoided.

Alas, there is no single rule to let you determine when to catch, when to rethrow, when to use checked and when to use unchecked exceptions. I agree this causes much confusion and a lot of bad code. The general principle is stated by Bloch (you quoted a part of it). And the general principle is to rethrow an exception to the layer where you can handle it.

2 of 16
257

Whether something is a "checked exception" has nothing to do with whether you catch it or what you do in the catch block. It's a property of exception classes. Anything that is a subclass of Exception except for RuntimeException and its subclasses is a checked exception.

The Java compiler forces you to either catch checked exceptions or declare them in the method signature. It was supposed to improve program safety, but the majority opinion seems to be that it's not worth the design problems it creates.

Why do they let the exception bubble up? Isnt handle error the sooner the better? Why bubble up?

Because that's the entire point of exceptions. Without this possibility, you would not need exceptions. They enable you to handle errors at a level you choose, rather than forcing you to deal with them in low-level methods where they originally occur.

Discussions

Checked vs Unchecked Exceptions in Java - Stack Overflow
I am having some problems with understanding the differences between checked and unchecked exceptions in Java. Firstly, checked exceptions are supposed to look for abnormalities during compile time. More on stackoverflow.com
🌐 stackoverflow.com
Checked vs unchecked
I think the main issue is that you're saying that the primary benefit of Hibernate is the checked vs unchecked exceptions. That's probably why they drilled down because that's just an incredibly tiny bit of why you might want to use an ORM. More on reddit.com
🌐 r/learnjava
7
6
November 11, 2023
Why are checked exceptions frowned upon?
In programming there are few absolutes. And exceptions are no exception. More on reddit.com
🌐 r/java
100
74
August 26, 2020
Some thoughts: The real problem with checked exceptions
Checked exceptions weren’t such a big issue to me if Java's Lambda implementation wouldn’t have been done the way it has been done and if checked exceptions would be easily propagated outside of Lambda calls. But because Lambda calls are beautified anonymous classes with abstract methods that often don’t declare exceptions as part of their method you can’t easily do that and that makes handling checked exceptions as part of Lambdas super ugly. More on reddit.com
🌐 r/java
189
35
June 1, 2024
🌐
Reddit
reddit.com › r/learnjava › exceptions - checked vs unchecked
r/learnjava on Reddit: Exceptions - Checked vs Unchecked
April 29, 2020 -

A checked exception required a throw clause on the method header but not for the unchecked exception?

What is the difference between the two? How do I know if it is unchecked vs checked?

🌐
Baeldung
baeldung.com › home › java › core java › checked and unchecked exceptions in java
Checked and Unchecked Exceptions in Java | Baeldung
January 8, 2024 - If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception.” · For example, before we open a file, we can ...
🌐
TheServerSide
theserverside.com › answer › What-are-checked-vs-unchecked-exceptions-in-Java
What are checked vs. unchecked exceptions in Java? | TheServerSide
When an exception must be handled with try-and-catch semantics, it is known as a checked exceptions. If try-and-catch semantics are not required, it is known as an unchecked exception.
🌐
Medium
medium.com › @AlexanderObregon › the-difference-between-checked-and-unchecked-exceptions-in-java-for-beginners-c3943786c40a
The Difference between Checked and Unchecked Exceptions in Java for Beginners
January 15, 2024 - Unlike checked exceptions, unchecked exceptions are not verified during compile time, which impacts how they are handled in the code. This section will delve into the nature of unchecked exceptions, their characteristics, and best practices ...
🌐
DEV Community
dev.to › realnamehidden1_61 › whats-the-difference-between-checked-exception-and-unchecked-exception-in-java-977
⚠️ What’s the Difference Between Checked Exception and Unchecked Exception in Java? - DEV Community
October 23, 2025 - Analogy: Like a cautious driver checking the route and car condition before a journey — Java wants you to handle these issues before the code even runs. Definition: Unchecked exceptions are not checked at compile-time.
Find elsewhere
🌐
Coding Shuttle
codingshuttle.com › home › handbooks › java programming handbook › checked vs unchecked exceptions in java: ultimate guide
Checked vs Unchecked Exceptions in Java: Ultimate Guide | Coding Shuttle
July 24, 2025 - Java File Class Java Reader and ... QuestionsJava Inner Classes Interview Questions ... Checked Exceptions – Exceptions that must be handled at compile time. Unchecked Exceptions – Exceptions that occur at runtime and ...
🌐
Rollbar
rollbar.com › home › how to handle checked & unchecked exceptions in java
How to Handle Checked & Unchecked Exceptions in Java
July 5, 2024 - Let's take a closer look at the differences with some examples. In broad terms, a checked exception (also called a logical exception) in Java is something that has gone wrong in your code and is potentially recoverable.
🌐
BYJUS
byjus.com › gate › difference-between-checked-and-unchecked-exceptions-in-java
Differences between Checked and Unchecked Exceptions ...
September 28, 2022 - There are two types of exceptions: ... A checked exception is an exception that should be reported in the method in which it is thrown. ... An exception that occurs at the runtime or at the time of execution is known as an unchecked exception.
Top answer
1 of 8
31

CheckedException needs to be handled by the caller, Unchecked exception don't.

So, when you design your application you should take in mind what kind of exceptional situation you are managing.

For example, if you design a validation method that checks the validity of some user input, then you know that the caller must check the validation exception and display the errors to the user in a nice looking way. This should be a checked exception.

Or, for those exceptional conditions that can be recovered: imagine you have a load balancer and you want notify the caller that one of the "n" servers is down, so the caller must recover the incident re-routing the message to another server; this should be a checked exception, because it is crucial that the caller (client) tries to recover the error, and don't just let the error to break the program flow.

Instead, there are many conditions that should not happen, and/or should instead break the program. For example, a programming error (like division by zero, null pointer exception), a wrong usage of an API (IllegalStateException, OperationNotSupportedException), an hardware crash, or just some minor situation that are not recoverable (lost connection to a server), or a doomsday :-) ; in those cases, the normal handling is to let the exception reach the most outer block of your code that displays to the user that an unpredictable error has occurred and the application can't do nothing to continue. It's a a fatal condition, so the only thing you can do is to print it to the logs or showing it to the user in the user interface. In those cases, catching the exception is wrong, because, after catching the exception you need to manually stop the program to avoid further damages; so it could be better to let some kind of exception "hit the fan" :)

For those reasons there are some exceptions that are Unchecked also in the JRE: OutOfMemoryError (unrecoverable), NullPointerException (it's a bug that needs to be fixed), ArrayIndexOutOfBoundsException (another bug example), and so on.

I personally think that also SQLException should be unchecked, since it denotes a bug in the program, or a connection problem to the database. But there are many examples where you get exception that you really don't have any clue in how to manage (RemoteException).

The best way to handle exceptions are: if you can recover or manage the exception, handle it. Otherwise let the exception pass out; somebody else will need to handle. If you are the last "somebody else" and you don't know how to handle an exception, just display it (log or display in the UI).

2 of 8
9
  1. you do not need to declare unchecked exceptions in a throws clause; but you must declare checked exceptions;
  2. RuntimeException and Error, and all of their subclasses (IllegalArgumentException, StackOverflowError etc), are unckecked exceptions; the fact that RuntimeException is unchecked, unlike other Throwable subclasses, is by design;
  3. there is no such thing as "compile time exceptions".

More generally, it is considered that unchecked exceptions are thrown in the event of either JVM errors or programmer errors. One famous such exception is NullPointerException, often abbreviated as NPE, which is a subclass of RuntimeException, and therefore unchecked.

Another very crucial difference between unchecked exceptions and checked exceptions is that within a try-catch block, if you want to catch unchecked exceptions, you must catch them explicitly.

Final note: if you have exception classes E1 and E2 and E2 extends E1, then catching and/or throwing E1 also catches/throws E2. This stands for both checked and unchecked exceptions. This has an implication on catch blocks: if you do differentiate between catching E2 and E1, you must catch E2 first.

For instance:

// IllegalArgumentException is unchecked, no need to declare it
public void illegal()
{
    throw new IllegalArgumentException("meh");
}

// IOException is a checked exception, it must be declared
public void ioerror()
    throws IOException
{
    throw new IOException("meh");
}

// Sample code using illegal(): if you want to catch IllegalArgumentException,
// you must do so explicitly. Not catching it is not considered an error
public void f()
{
    try {
        illegal();
    } catch (IllegalArgumentException e) { // Explicit catch!
        doSomething();
    }
}

I hope this makes things clearer...

🌐
How to do in Java
howtodoinjava.com › home › exception handling › java checked vs unchecked exceptions
Java - Checked vs Unchecked Exceptions (with Examples)
December 20, 2022 - Remember, the biggest difference between checked and unchecked exceptions is that checked exceptions are forced by the compiler and used to indicate exceptional conditions that are out of the program’s control, while unchecked exceptions occur during runtime and are used to indicate programming errors. Happy Learning !! ... A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies.
🌐
Medium
medium.com › @ayoubtaouam › checked-vs-unchecked-exceptions-in-java-designing-better-error-handling-1af36090e0a5
Checked vs Unchecked Exceptions in Java: Designing Better Error Handling
October 30, 2025 - If you forget the try-catch, Java complains immediately. Use checked exceptions when the caller can reasonably recover from the failure. ... File not found: maybe ask the user to pick another file.
🌐
W3Schools
w3schools.in › java › questions-answers › difference-between-checked-and-unchecked-exceptions-in-java
Difference Between Checked and Unchecked Exceptions in Java
If found, the exception is handled or resolved, or else the program execution stops. Java generates two types of exceptions.
🌐
Scaler
scaler.com › home › topics › checked and unchecked exception in java
Checked and Unchecked Exception in Java - Scaler Topics
February 11, 2022 - Unchecked Exceptions, on the other hand, are not required to be declared or caught. They are checked by the Java Virtual Machine at runtime. Some common examples of Checked Exceptions include IOException, ParseException, and ClassNotFoundException, ...
🌐
BeginnersBook
beginnersbook.com › 2013 › 04 › java-checked-unchecked-exceptions-with-examples
Checked and unchecked exceptions in java with examples
There are two types of exceptions: checked exception and unchecked exception. In this guide, we will discuss them. 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.
🌐
Medium
medium.com › @ahmed.abdelfaheem › checked-and-unchecked-exceptions-in-java-6cb1c9815d32
Checked and Unchecked Exceptions in Java | by Ahmed Safwat | Medium
August 12, 2023 - When working with exceptions in ... and reliability of your code: Use checked exceptions for expected error scenarios that can be recovered from and unchecked exceptions for programming errors....
🌐
Cs1302uga
cs1302uga.github.io › cs1302-book › java › exceptions › checked-vs-unchecked.html
3.7. Checked vs. Unchecked Exceptions - CSCI 1302
Checked exceptions must be explicitly caught or propagated by the programmer, whereas unchecked exceptions are not required to be handled by the programmer (the programmer can let them automatically propagate). In this section, we will see two short programs.
🌐
Scientech Easy
scientecheasy.com › home › blog › checked and unchecked exceptions in java
Checked and Unchecked Exceptions in Java - Scientech Easy
January 19, 2026 - But, at runtime, FileNotFoundException exception occurs because we are trying to access a non-existing file. Unchecked exceptions in Java are those exceptions that are checked by JVM, not by java compiler.
🌐
Medium
medium.com › @niteeshboddapu › checked-vs-unchecked-exceptions-in-java-a-complete-guide-f9a78c18e5dd
Checked vs Unchecked Exceptions in Java — A Complete Guide | by Niteesh Boddapu | Medium
September 28, 2025 - Checked exceptions are exceptions that the compiler forces you to handle using either try-catch or by declaring them with throws. Usually caused by external problems beyond your control — such as files, databases, or networks.