Java Exception Handling Interview Questions 2026: 26 Q&A

What changed in 2026 drives
Mass-recruiter offer letters are flatter for 2026 batch - the 4-5 LPA ASE band has barely budged in three years while inflation eats real wages. Premium tracks (Digital, Pro, Elite, Specialist) are still where the differential lives, and they are entirely test-driven. If you are aiming higher than the default offer, the coding round is not optional pageantry - it is the entire interview.
What I'd actually study for this
- 01Two solid coding-round answers (1 medium-hard DSA each, with edge-case discussion) > five half-baked ones
- 02One real project you can defend end-to-end - file paths, design decisions, and what you would change
- 03One DBMS schema you actually built (not a textbook ER diagram), with at least 3 join-heavy queries written from memory
- 04Three behavioural STAR stories: failure recovered, conflict handled, ownership taken
Where most candidates trip up
The single biggest mistake is treating company-specific guides as primary prep and DSA as secondary. It is the opposite. Mass recruiters use the test as a filter, but premium tracks at every IT services company use coding to allocate offer band. Spend 70% of prep time on DSA + system fundamentals, 20% on company-specific patterns, 10% on HR rehearsal. Reverse that ratio and you collect the default offer.
Editorial commentary by Aditya Sharma · written for PapersAdda · not generated, not aggregated.
Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~15 min
Exception handling is a guaranteed topic in Java interviews. Candidates report that interviewers love the checked-versus-unchecked distinction, the finally plus return trap, and custom exception design. This guide covers 26 questions with full answers, runnable code, and the gotchas interviewers use to separate rote learners from people who understand control flow. Behaviour reflects the official Oracle Java tutorials; confirm spec-level details against JLS chapter 11.
Pair this with Java Interview Questions 2026 and Java OOPs Interview Questions 2026.
Table of Contents
- Fundamentals (Q1 to Q9)
- Control Flow and finally (Q10 to Q16)
- Custom and Advanced (Q17 to Q22)
- Best Practices (Q23 to Q26)
- Predict the Output
- Exception Hierarchy Table
- Frequently Asked Questions
Fundamentals
Q1. What is an exception in Java? Easy
Q2. What is the difference between an error and an exception? Easy
Q3. What is the difference between checked and unchecked exceptions? Medium
| Type | Examples | Compile-time check |
|---|---|---|
| Checked | IOException, SQLException | Yes |
| Unchecked | NullPointerException, ArrayIndexOutOfBoundsException | No |
| Error | OutOfMemoryError, StackOverflowError | No |
Q4. What is the exception hierarchy in Java? Easy
Q5. What is the difference between throw and throws? Easy
Q6. Can a try block exist without a catch? Medium
Q7. Can you catch multiple exceptions in one catch? Medium
try { risky(); }
catch (IOException | SQLException e) { log(e); }
Q8. What is exception chaining? Medium
catch (SQLException e) {
throw new DataAccessException("query failed", e); // preserves cause
}
Q9. What happens if an exception is not caught anywhere? Medium
Control Flow and finally
Q10. What is the finally block and when does it run? Easy
Q11. Does finally run if there is a return in try? Hard
int test() {
try { return 1; }
finally { return 2; } // overrides; method returns 2
}
Q12. What happens if both try and finally throw exceptions? Hard
Q13. What is try-with-resources? Medium
try (BufferedReader br = new BufferedReader(new FileReader("f.txt"))) {
return br.readLine();
} // br.close() called automatically
Q14. What is a suppressed exception? Hard
Q15. Can you have nested try blocks? Medium
Q16. What is the order of catch blocks? Medium
Custom and Advanced
Q17. How do you create a custom exception? Medium
class InsufficientFundsException extends RuntimeException {
InsufficientFundsException(String msg) { super(msg); }
}
Q18. When should a custom exception be checked vs unchecked? Hard
Q19. What is the difference between final, finally, and finalize? Medium
Q20. Can a constructor throw an exception? Medium
Q21. What happens to an exception thrown in a finally during stack unwinding? Hard
Q22. How does exception handling work with method overriding? Hard
Best Practices
Q23. Why is catching Exception or Throwable broadly bad? Medium
Q24. Why should you not use exceptions for control flow? Medium
Q25. What should you log when handling an exception? Easy
Q26. What is the cost of throwing an exception? Hard
Predict the Output
Snippet 1
public static int f() {
try { return 1; }
finally { System.out.println("finally"); }
}
System.out.println(f());
Output:
finally
1
Why: finally runs after the return value (1) is computed but before the method returns, so "finally" prints first, then the returned 1.
Snippet 2
try {
int[] a = new int[2];
a[5] = 1;
System.out.println("after");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("caught");
} finally {
System.out.println("done");
}
Output:
caught
done
Why: The out-of-bounds write throws before "after" prints, control jumps to the matching catch, then finally always runs.
Snippet 3
public static int g() {
try { return 1; }
finally { return 2; }
}
System.out.println(g());
Output:
2
Why: A return inside finally overrides the try's return. The method returns 2, the value 1 is discarded. This is the classic trap question.
Exception Hierarchy Table
| Level | Class | Recoverable | Compile-checked |
|---|---|---|---|
| Root | Throwable | n/a | no |
| Serious | Error | no | no |
| General | Exception | yes | yes (most) |
| Runtime | RuntimeException | sometimes | no |
Frequently Asked Questions
What is the most asked exception handling question in 2026?
Candidates report that the difference between checked and unchecked exceptions, and the behaviour of finally when try has a return, are the two most repeated questions in Java rounds.
Is try-with-resources important for interviews?
Yes. Interviewers expect you to use try-with-resources for any closeable resource and to explain that it auto-closes in reverse order of declaration and suppresses secondary exceptions rather than masking the primary one.
Can finally override a return value?
Yes, and it is a known trap. A return inside finally overrides any return or exception from try or catch, which is exactly why returning from finally is considered bad practice.
What is the difference between final, finally, and finalize?
final is a modifier for constants and non-overridable members, finally is the always-run block after try, and finalize is a deprecated pre-GC hook you should never rely on. Interviewers ask this to test attention to detail.
Should custom exceptions be checked or unchecked?
Make it checked when the caller can recover and you want to force handling; make it unchecked for programming errors or unrecoverable conditions. Modern codebases often lean unchecked to keep method signatures clean.
Related Articles
- Java Interview Questions 2026, the master 50-question set
- Java OOPs Interview Questions 2026, OOP foundations
- Java Multithreading Interview Questions 2026, concurrency rounds
- Java String Interview Questions 2026, strings and immutability
Confirm any spec-level exception semantics against the official JLS and Oracle tutorials before your interview. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.
Methodology applied to this articlelast verified 8 Jun 2026
- No fabricated salary numbers or success rates. If we quote a range, it's sourced.
- No noun-substituted templates. This article was not generated by swapping company names in a stock prompt.
- No paid placements, sponsored coaching links, or affiliate-shilled course pushes.
Explore this topic cluster
More resources in Interview Questions
Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.
Paid contributor programme
Sat this this year? Share your story, earn ₹500.
First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story - with byline.
Submit your story →Ready to practice?
Take a free timed mock test
Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.
Start Free Mock Test →Related Articles
Airbnb Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Airbnb's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
Airtel Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Airtel's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
AMD Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing AMD's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
Atlassian Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Atlassian's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical,...
Barclays Interview Questions 2026
_Last verified by [Aditya Sharma](/author/aditya-sharma/) · cross-checked against PapersAdda Hiring Pulse and...
More from PapersAdda
Accenture Interview Process 2026: Rounds & Prep
Accenture Interview Questions 2026 (with Answers for Freshers)
Adobe Interview Process 2026: Rounds, OA & Aptitude
Amazon Interview Process 2026: Full Loop + Bar Raiser