Question 174 of 513
Exception Handling Best Practices
Which THREE practices are recommended for effective exception handling? (Choose three.)
Quick Answer
The answer is to use specific exception types in catch blocks rather than catching the generic Exception class. This practice is fundamental to exception handling best practices in Java because it preserves the granularity of error information, allowing each catch block to respond precisely to the distinct failure scenario it was designed for. Catching a broad Exception can mask unexpected runtime issues, making debugging and maintenance significantly harder. On the Oracle Certified Professional Java SE 17 Developer 1Z0-829 exam, this concept frequently appears in questions about effective exception handling, often testing your ability to distinguish between catching specific checked exceptions versus a blanket catch-all. A common trap is assuming that catching Exception is harmless for logging purposes, but the exam emphasizes that it violates the principle of separation of concerns by handling unrelated errors at the same level. Remember the mnemonic “Be Specific, Not Generic” to reinforce that each catch block should target only the exception type it can meaningfully resolve.
⚠ Common exam trap
Oracle often tests the misconception that catching exceptions at the highest level with generic logging is a good practice, when in fact it hides errors and violates the principle of handling exceptions at the appropriate level.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Throw exceptions early, catch them late, but handle them at the appropriate level.
Effective exception handling in Java recommends throwing exceptions as soon as an error is detected (fail-fast), catching them at a level where the error can be meaningfully handled (not too early), and handling them at the appropriate layer of abstraction. This prevents swallowing exceptions or losing context, and aligns with the principle of separation of concerns.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Throw exceptions early, catch them late, but handle them at the appropriate level.
Why this is correct
Best practice: throw at point of error, catch where recovery is possible.
- ✗
Define custom exceptions without providing any additional context.
Why it's wrong here
Custom exceptions should include useful information.
- ✓
Use try-with-resources for automatic resource management instead of manual close in finally.
Why this is correct
Cleaner and safer resource handling.
- ✗
Catch exceptions at the highest level of the application and log them generically.
Why it's wrong here
Catching Exception broadly is discouraged; handle where possible.
- ✓
Use specific exception types in catch blocks rather than catching Exception.
Why this is correct
Improves error handling specificity.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on 1Z0-829
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A developer is implementing a method that reads a file and parses its contents. The method should ensure that any resources opened during the process are properly closed, even if an exception occurs. Which approach guarantees resource closure with minimal code?
medium- ✓ A.Use try-with-resources with the resource declared in the try clause.
- B.Use a try-catch block and close the resource inside the catch block.
- C.Use a try block followed by a finally block without catch.
- D.Use a try-catch-finally block and call close() in the finally block.
Why A: Try-with-resources automatically closes any resource that implements `AutoCloseable` (or `Closeable`) at the end of the try block, regardless of whether an exception occurs. This guarantees resource closure with minimal code, as the developer does not need to write explicit `close()` calls or manage finally blocks.
Last reviewed: Jun 30, 2026
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.