throw vs throws in Java — Keyword, Clause, and When to Use Each
Fast recall
Quick revision
Core answer
throw is a statement that actually raises an exception at runtime — throw new IllegalArgumentException("negative amount"). throws is a method-signature clause that declares which checked exceptions a method can propagate — void save() throws IOException. You throw one exception instance; you throws a comma-separated list of exception types. Unchecked exceptions don't need to be in throws. Java 7+ lets you throws multiple checked types and rethrow them from a single catch (Exception e) via precise rethrow analysis.Whether the candidate can distinguish the keyword `throw` (statement that raises an exception) from the clause `throws` (signature declaration), and knows the rules about when each is required
Adding `throws RuntimeException` to method signatures (legal but pointless), forgetting that `throws` only matters for checked exceptions, or thinking `throw` and `throws` are interchangeable
Mention Java 7+ precise rethrow analysis — a `catch (Exception e)` block can rethrow specific checked subtypes without the method needing `throws Exception`. Show how `throws` is part of the method's API contract and overriding methods can only throw narrower (or same) checked exceptions
Interview-ready guide
Interview answer
The quick way to keep them straight: throw is an action, throws is a declaration.
`throw` — the statement
- Appears inside a method body:
throw new IllegalArgumentException("negative amount") - Actually raises one exception instance per statement
- Works for both checked and unchecked — any
Throwable
`throws` — the clause
- Appears on the method signature:
void save() throws IOException, SQLException - Declares checked exceptions that can propagate out of the method
- Unchecked exceptions don't need to be listed — it's legal but pointless
- Forces callers to either catch those exceptions or add them to their own
throws
Override rule
- A subclass override can throw the same checked exceptions, narrower subtypes, or nothing at all — never broader or unrelated types
- This preserves Liskov substitutability so callers coded against the parent don't get surprise checked exceptions
Java 7+ precise rethrow
catch (Exception e) { throw e; }no longer forcesthrows Exceptionon the method- The compiler tracks which specific checked types the try block could produce, so a narrow
throwsclause still compiles - Requires the caught variable to be effectively final
Recommendation: Keep throws clauses as narrow as possible — they're part of the API contract and every widening forces every caller to handle more. Use throw to enforce preconditions with unchecked exceptions (argument validation) and to raise domain-specific checked exceptions only when callers genuinely have a recovery path.
`throw` vs `throws` in Java — Keyword, Clause, and When to Use Each
Direct Answer
throw is a statement that actually raises an exception at runtime — throw new IllegalArgumentException("negative amount"). throws is a method-signature clause that declares which checked exceptions a method can propagate — void save() throws IOException. You throw one exception instance; you throws a comma-separated list of exception types. Unchecked exceptions don't need to be in throws. Java 7+ lets you throws multiple checked types and rethrow them from a single catch (Exception e) via precise rethrow analysis.
Common Mistakes & Pitfalls
Adding throws RuntimeException to method signatures (legal but pointless), forgetting that throws only matters for checked exceptions, or thinking throw and throws are interchangeable
Check your understanding
Answer these without looking back at the article.
- If a method throws a RuntimeException, should it still declare it in the throws clause? Why or why not?
- Why can't an overriding method broaden the throws clause?
- What is Java 7's precise rethrow analysis, and what condition does the caught variable need to satisfy?
- Can a static initializer block declare a throws clause? Why?
- How do lambdas handle checked exceptions — why can't `Runnable.run()` throw IOException?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.