Quick revision
The short answer
Throwable is the root of everything that can be thrown, and it has two direct subclasses: Error and Exception. Exception and its subclasses are checked, except RuntimeException and its subclasses, which are unchecked, and Error and its subclasses are unchecked too. Errors such as OutOfMemoryError or LinkageError signal serious problems the application usually cannot recover from, so catching Throwable or Error in ordinary code can hide them and keep a JVM running in an unknown state; only top-level handlers, such as an uncaught exception handler or a framework's error handler, should catch Throwable, and then to log and shut down or fail cleanly.
What to remember
In this answer, we saw that Throwable has two direct subclasses, Error and Exception. Exceptions are checked unless they extend RuntimeException, and Errors are unchecked. Errors such as OutOfMemoryError and LinkageError signal problems the application usually cannot recover from, so catching Throwable or Error in ordinary code hides them and keeps a damaged JVM running. Only top-level handlers, such as uncaught exception handlers and framework error handlers, should catch Throwable, and then to log, report and fail fast.
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.
Throwable is the root of everything that can be thrown, and it has two direct subclasses: Error and Exception. Exception and its subclasses are checked, except RuntimeException and its subclasses, which are unchecked, and Error and its subclasses are unchecked too. Errors such as OutOfMemoryError or LinkageError signal serious problems the application usually cannot recover from, so catching Throwable or Error in ordinary code can hide them and keep a JVM running in an unknown state; only top-level handlers, such as an uncaught exception handler or a framework's error handler, should catch Throwable, and then to log and shut down or fail cleanly.
Why this question is asked
Every Java developer writes catch blocks, but many are unsure which exceptions the compiler forces them to handle and why catching everything is a bad idea. Interviewers ask about the Throwable hierarchy because it is the foundation for every later question on exception design, from checked exceptions to Spring's error handling. In this answer, we will draw the hierarchy, see which branches are checked, look at what Errors mean, see what goes wrong when code catches Throwable, and finish with the few places where catching it is right.
1The Shape of the Hierarchy
Anything we can throw with throw or catch with catch must be a Throwable. A Throwable carries a message, an optional cause (another Throwable that led to this one), a stack trace and a list of suppressed exceptions. Below it the tree splits in two.
| Branch | Checked? | Typical examples |
|---|---|---|
| Error and subclasses | No | OutOfMemoryError, StackOverflowError, LinkageError |
| Exception (not runtime) | Yes | IOException, SQLException, InterruptedException |
RuntimeException and subclasses | No | NullPointerException, IllegalArgumentException |
| Throwable itself, if thrown | Yes | rare; treated as checked by javac |
2Checked and Unchecked Branches
A checked exception is one the compiler makes us deal with: a method that can throw it must either catch it or declare it with throws. The rule is simple once we see the tree: Throwable and Exception subclasses are checked, unless they are below RuntimeException or Error.
RuntimeExceptions usually mean a bug in the calling code, a null where one was not allowed or an illegal argument, so forcing every caller to declare them would add noise without helping. Errors are unchecked because no ordinary method can sensibly promise to handle running out of memory.
3What an Error Tells Us
An Error signals a problem in the JVM or the environment, not in our business logic. OutOfMemoryError means the heap, or another memory area such as metaspace, is exhausted. StackOverflowError means recursion went too deep. LinkageError and its subclasses, such as NoClassDefFoundError, mean a class that compiled fine cannot be loaded or linked at run time, often because of a missing jar or a static initialiser that failed earlier.
The key point is that after an Error, the program's state is uncertain. An OutOfMemoryError can be thrown in the middle of any allocation, so a data structure may be half updated, a lock may not have been released properly, and other threads may be failing too. Recovery code that itself allocates memory may fail again. That is why the guidance is that applications usually should not try to recover from Errors.
4What Goes Wrong When We Catch Throwable
Catching Throwable catches Errors along with everything else, and the usual catch-all code treats them like ordinary failures.
Notice two harms. The loop continues on a JVM that may be in an unknown state, so later failures appear in unrelated places. And the real signal, an Error that should have restarted the process, is reduced to a warning in a log. In ordinary code, we catch the most specific Exception types we can actually handle.
5Where Catching Throwable Is Right
There is one legitimate place: the very top of a thread or a request, where the job is not to recover but to record the failure and react safely. A thread's uncaught exception handler, a framework's top-level error handler, or the outer loop of a worker thread may catch Throwable, log it with full detail, report it to monitoring, and then either fail the request cleanly or shut down.
- Ordinary code: can I handle this specific Exception?YesCatch that type and recoverNoLet it propagate
- Top-level boundary: thread, request, worker loop?YesCatch Throwable, log and reportNoDo not catch Throwable
- Was it an Error?YesFail fast and let the process restartNoFail the request cleanly
3 steps in order. Play them, or step through them one at a time.
For memory errors specifically, it is safer to let the JVM handle it with flags such as -XX:+ExitOnOutOfMemoryError and -XX:+HeapDumpOnOutOfMemoryError, so the process exits and a heap dump is saved for analysis, rather than relying on our own catch block running correctly while memory is exhausted.
6Follow-up questions
Is catching Exception as bad as catching Throwable?
It is less dangerous, because it does not catch Errors, but it is still broad: it catches every RuntimeException, so bugs such as NullPointerException are handled as if they were expected failures. Catch Exception at boundaries, not deep in business code.
Can we ever recover from StackOverflowError?
Sometimes, because the stack unwinds as the error propagates and memory is freed. But code may have been interrupted at any point, including inside a lock or a static initialiser, so the safest course is still to treat it as a bug to fix, not a condition to handle.
Is it possible to throw a checked exception without declaring it?
javac enforces declarations, but the JVM does not check them. Tricks such as a generic sneaky throw, or code written in other JVM languages, can throw checked exceptions from methods that do not declare them, which is why boundary handlers should not assume only RuntimeExceptions arrive.
7Conclusion
In this answer, we saw that Throwable has two direct subclasses, Error and Exception. Exceptions are checked unless they extend RuntimeException, and Errors are unchecked. Errors such as OutOfMemoryError and LinkageError signal problems the application usually cannot recover from, so catching Throwable or Error in ordinary code hides them and keeps a damaged JVM running. Only top-level handlers, such as uncaught exception handlers and framework error handlers, should catch Throwable, and then to log, report and fail fast.
Open with
At the top is Throwable, which has two direct subclasses, Error and Exception. Exception and everything under it is checked, meaning the compiler forces us to catch or declare it, except RuntimeException and its subclasses, which are unchecked.
Then, if they want more
Error and its subclasses are also unchecked. So IOException and SQLException are checked, NullPointerException and IllegalArgumentException are unchecked runtime exceptions, and OutOfMemoryError and StackOverflowError are unchecked errors. Errors mean the JVM or the environment is in trouble: memory is exhausted, the stack overflowed, or a class could not be linked, like NoClassDefFoundError.
After one of those, the program state is uncertain; an OutOfMemoryError can hit in the middle of any allocation and leave data half updated. That is why ordinary code should not catch Throwable or Error: it turns a fatal signal into a log line and keeps a damaged JVM running, and failures then appear in random places.
In normal code I catch the specific exceptions I can actually handle. The exception is top-level boundaries, like an uncaught exception handler, a worker loop or a framework's error handler, where catching Throwable to log, report and fail cleanly or shut down is correct. For memory errors I prefer ExitOnOutOfMemoryError plus a heap dump, so the process restarts cleanly.
About this answer
- Last updated
- 12 November 2026
- 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 "Describe the Throwable hierarchy: Error, Exception, RuntimeException. Which are checked...": https://scrivio-interview-library.netlify.app/java/exceptions/6c90dcce5a/