Quick revision
The short answer
Java added checked exceptions to make error handling explicit and compiler-enforced, building on ideas from earlier languages with declared exceptions. In practice they leak implementation details into signatures, turn adding an exception into a breaking change for every caller, and work poorly with higher-order functions and generic code, which is why Kotlin treats all exceptions as unchecked and Java itself added UncheckedIOException and unchecked-friendly APIs. For a large Java organization today, I would avoid new checked exceptions in internal APIs, model expected outcomes in return types, and handle infrastructure failures at boundaries.
What to remember
In this answer, we saw that Java added checked exceptions to make error handling explicit and enforced, and that the idea works for direct, local handling. At scale they leak implementation details, make adding an exception a breaking change, and fit poorly with lambdas and generic code, so Kotlin, Scala and C# treat all exceptions as unchecked and Java itself added UncheckedIOException and unchecked-friendly APIs. The policy we set is no new checked exceptions in internal APIs, expected outcomes modelled in return types such as sealed results, and infrastructure failures translated at adapters and handled at boundaries.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Java added checked exceptions to make error handling explicit and compiler-enforced, building on ideas from earlier languages with declared exceptions. In practice they leak implementation details into signatures, turn adding an exception into a breaking change for every caller, and work poorly with higher-order functions and generic code, which is why Kotlin treats all exceptions as unchecked and Java itself added UncheckedIOException and unchecked-friendly APIs. For a large Java organization today, I would avoid new checked exceptions in internal APIs, model expected outcomes in return types, and handle infrastructure failures at boundaries.
Background to this question
Checked exceptions are one of the few Java features that no later mainstream language copied, including the JVM languages that share Java's runtime. A senior engineer should be able to explain that history fairly: what problem the feature was meant to solve, where it worked, why it disappointed, and what a team should do today with a codebase and a JDK that still contain thousands of checked exceptions. In this answer, we will recap the intent, look at the three main problems with real examples, see how Kotlin, Scala and the JDK itself responded, and set out a policy for a large organization.
1Why Java Has Checked Exceptions
When Java was designed in the early 1990s, a common source of bugs in C programs was ignored error codes: a function returned -1, and the caller never looked. Java's designers wanted errors that could not be ignored silently. A checked exception is part of a method's signature, and the compiler refuses to compile a call unless the caller catches the exception or declares it in turn.
The idea was not new; earlier languages such as CLU and Modula-3 had declared exceptions, and Java made the check strict and universal. For some failures, the design fits well: a method that reads a file really can fail for reasons outside the program's control, and a caller that forgets that is wrong. The intent was sound. The problems came from how the feature behaves in large, evolving systems.
2Problem 1: Signatures Leak Implementation and Resist Change
A throws clause tells callers not only that something can fail, but how it is implemented. A UserRepository whose find method throws SQLException announces that it uses JDBC. If we later move users to a REST service, the honest exception would be IOException, and changing the clause changes the method's contract.
Changing that contract is a versioning problem. Adding a checked exception to a published method breaks every caller's build, because each one must now catch or declare it. In a library used by hundreds of services, that is a major-version change for what might be a small internal improvement. The usual escape, wrapping everything into one broad exception such as DataAccessFailure, keeps the signature stable but tells callers almost nothing, which defeats the purpose.
3Problem 2: Checked Exceptions and Higher-Order Code
Checked exceptions were designed before Java had lambdas. Generic code that takes a function as an argument, such as Stream.map or CompletableFuture.supplyAsync, cannot know which checked exceptions that function might throw, and the standard functional interfaces declare none. So a lambda that calls a method throwing a checked exception does not compile in those positions.
| Code style | Fit | Why |
|---|---|---|
| Direct call, caller can recover | Good | compiler ensures handling |
| Deep call stack, handled at top | Poor | every layer must declare or wrap |
| Lambdas and streams | Poor | functional interfaces declare no checked exceptions |
| Evolving library API | Poor | adding one breaks every caller |
| Generic code over any function | Poor | throws clause cannot be abstracted well |
Java's type system cannot easily express a function that throws whatever its argument throws; generic throws clauses such as <E extends Exception> help in a single method but do not scale through stream pipelines. The result is that checked exceptions and functional style pull in opposite directions, and functional style has won in modern Java code.
4How Kotlin, Scala and the JDK Responded
Kotlin and Scala run on the JVM and call Java libraries constantly, yet both treat all exceptions as unchecked. They can do this because the checked rule exists only in javac; the JVM never enforces throws clauses. Kotlin offers @Throws only so that Java callers see a throws clause. C#, designed a few years after Java, also chose not to have checked exceptions.
Java itself moved in the same direction without removing the feature. Java 8 added UncheckedIOException and used it in APIs such as Files.lines and BufferedReader.lines, where an IOException during stream processing is wrapped because a stream cannot throw it. Newer APIs, such as the java.net.http HttpClient's async methods and much of java.time, favour unchecked exceptions or results carried in a CompletableFuture. The checked exceptions in older APIs remain for compatibility.
5Why the Experiment Is Judged Mixed
It is fair to say checked exceptions achieved their goal in small, direct code: nobody forgets that opening a file can fail. They fall short in the code most organizations now write: layered services, shared libraries that must evolve, and pipelines of lambdas. There, the common outcomes are wrapping, broad throws Exception clauses and swallowed exceptions, which are worse than an honest unchecked exception, because a swallowed failure is invisible. That mix of a good idea with poor results at scale is why the experiment is usually described as mixed rather than a simple failure.
- Repository throws SQLException
- Can the caller recover here?YesHandle it (rare)NoMust catch or declare anyway
- Developer declares it?Yesthrows spreads up every layerNocatch and wrap, or swallow
- Boundary finally handles itthe same place an unchecked one would reach
4 steps in order. Play them, or step through them one at a time.
6A Policy for a Large Java Organization
First, avoid introducing new checked exceptions in internal APIs. New exception types extend RuntimeException, belong to a small named hierarchy per domain, and are documented with @throws on public methods.
Second, model expected outcomes in return types. When a caller must make a decision, such as a payment declined, a user not found or a booking unavailable, the method returns a value that says so: an Optional for absence, or a sealed interface of result records, which the caller handles with a switch the compiler checks for completeness. This keeps the compile-time guarantee checked exceptions promised, without breaking lambdas.
Third, handle infrastructure failures at boundaries. Database, network and serialization failures propagate as unchecked exceptions, translated at the adapter (as Spring does with DataAccessException), and are handled once: in a controller advice, a message listener error handler or a job wrapper, where they are logged, counted, retried if transient, and mapped to a response. Checked exceptions from the JDK and libraries are translated at the edge of the adapter that calls them, never passed further, and never swallowed.
7Follow-up questions
Would you ever remove checked exceptions from existing public APIs?
Only with a major version and a migration path, because removing a checked exception from a throws clause can also break callers: their catch blocks for it may stop compiling, as catching a checked exception that cannot be thrown is an error. For internal code, migrating gradually as modules are touched is usually enough.
Isn't a sealed result type just as verbose?
It is somewhat verbose at the definition, but at the call site a switch over a sealed type is short, readable and checked for completeness, and it works inside streams and async code. The verbosity is also limited to the few operations with real business outcomes.
What about InterruptedException?
It is a special case worth keeping checked in spirit: when we catch it, we must restore the interrupt flag with Thread.currentThread().interrupt() or rethrow, so that cancellation still works. A policy should call that out explicitly rather than letting it be wrapped and forgotten.
8Conclusion
In this answer, we saw that Java added checked exceptions to make error handling explicit and enforced, and that the idea works for direct, local handling. At scale they leak implementation details, make adding an exception a breaking change, and fit poorly with lambdas and generic code, so Kotlin, Scala and C# treat all exceptions as unchecked and Java itself added UncheckedIOException and unchecked-friendly APIs. The policy we set is no new checked exceptions in internal APIs, expected outcomes modelled in return types such as sealed results, and infrastructure failures translated at adapters and handled at boundaries.
Open with
Java added checked exceptions to stop errors being silently ignored, as error codes often were in C. The exception is part of the signature and the compiler forces every caller to catch or declare it, which built on ideas from earlier languages with declared exceptions.
Then, if they want more
For direct code where the caller can recover, that works. The trouble shows up at scale. Throws clauses leak implementation: a repository declaring SQLException tells everyone it uses JDBC, and adding a new checked exception later breaks every caller's build, so it becomes a versioning problem.
They also clash with higher-order code: Function and the other functional interfaces cannot throw checked exceptions, so streams and lambdas need wrapping. In practice, people end up wrapping, declaring throws Exception, or swallowing failures, which is worse than an unchecked exception.
That is why Kotlin and Scala, on the same JVM, made everything unchecked, and why Java itself added UncheckedIOException and newer APIs that avoid checked ones.
For a large organization today, my policy would be: no new checked exceptions in internal APIs; model expected business outcomes in return types, like Optional or a sealed result type the compiler checks in a switch; translate library checked exceptions at the adapter; and handle infrastructure failures once, at boundaries, with logging, retries and proper responses.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 8
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Checked exceptions are a Java-specific feature that later JVM languages such as Kotlin...": https://scrivio-interview-library.netlify.app/java/exceptions/38263746ec/