Interview Q&A / Java

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is the difference between throw and throws in Java?

SHORT ANSWER

throw is a statement that actually raises one exception object at that moment. throws is part of a method signature that warns callers which checked exceptions the method might pass on.

Explain it simply

A referee who shows a red card is doing throw: it happens right now, to a specific player. A notice on the stadium gate saying "play may be stopped for rain or injury" is throws: it declares what might happen.

Example

java
static void withdraw(double balance, double amount) throws Exception {   // declaration
    if (amount > balance) {
        throw new Exception("Insufficient balance");                      // action
    }
    System.out.println("Collect cash");
}

try {
    withdraw(500, 800);
} catch (Exception e) {
    System.out.println(e.getMessage());   // prints: Insufficient balance
}

What to say in the interview

"throw is used inside a method body with one exception instance, for example throw new IllegalArgumentException(...). throws appears after the parameter list and can list several exception classes separated by commas. A checked exception must either be caught or declared with throws, otherwise the code will not compile. Unchecked exceptions can be thrown without any declaration."

Common mistakes

  • Writing throws followed by new Exception(). throws takes class names, throw takes an object.
  • Declaring throws Exception everywhere, which gives callers no useful information.

#java#exceptions#basics

Related questions

Practise more Java questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Java quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.