Practice 1Z0-829 Handling Exceptions questions with full explanations on every answer.
Start practicing
Handling Exceptions — choose a session length
Free · No account required
Click any question to see the full explanation and answer options, or start a focused practice session above.
A developer is writing a method that reads a file and processes its content. The method must ensure that if an IOException occurs during reading, the method throws a custom ApplicationException that wraps the original IOException, and that any resources opened are closed properly. Which approach correctly implements this requirement?
2A team is designing a logging framework. The framework's core method log(String message) may throw a checked LogException if the logging system fails. The team wants to allow callers to choose whether to handle the exception or declare it as thrown. Which declaration of the log method satisfies this requirement?
3Which TWO statements about the try-with-resources statement are correct? (Choose two.)
4What is the result when the main method is executed?
5You are responsible for a Java 17 application that processes user uploads. The application uses a custom AutoCloseable resource, UploadSession, which must always be closed after use to free server resources. A junior developer wrote the following code: ``` UploadSession session = new UploadSession(); try { session.upload(data); // more processing } catch (UploadException e) { log.error("Upload failed", e); } finally { session.close(); } ``` During a code review, you notice that the close() method of UploadSession throws a checked CloseException. The current code does not handle this exception. Which course of action should you recommend to ensure the application is robust and follows best practices?
6Which TWO of the following are checked exceptions in Java?
7Given the stack trace, which statement is true about the exception handling?
8You are developing a microservice that processes financial transactions. The service reads transaction data from a message queue, validates it, and writes results to a database. The code uses a try-with-resources statement to manage database connections. During testing, you notice that when a transaction fails validation, the service throws an IllegalStateException before closing the database connection, causing a resource leak. You need to ensure that the database connection is always closed properly, even if an exception is thrown during validation. The current code structure is: try (Connection conn = DriverManager.getConnection(url, user, pass)) { // read from queue // validate transaction // if invalid, throw new IllegalStateException("Invalid transaction"); // write to database } Which course of action would you recommend?
9Which TWO statements about the try-with-resources statement are true? (Choose two.)
10What is the output when the code is executed?
11You are developing a microservice that processes order payments. The service uses a custom exception hierarchy: PaymentException (checked), InsufficientFundsException (unchecked, extends RuntimeException), and NetworkException (checked, extends PaymentException). The processPayment method is declared as: public void processPayment(Order order) throws PaymentException. Inside, a call to an external payment gateway may throw InsufficientFundsException or NetworkException. The requirement is to log all payment failures to an audit system, but the service must continue processing other orders. The audit logging method is: public void logFailure(String message) throws Exception. Which approach best handles exceptions while meeting the requirements?
12Order the steps to compile and run a simple Java program from the command line.
13Match each JDBC type to its corresponding Java type.
14A method reads a file and throws IOException. Which of the following is the correct way to declare the method?
15Consider the following code snippet: try { // some code } catch (IOException e) { // handle } catch (FileNotFoundException e) { // Line X // handle } What will be the result?
16Given a try-with-resources statement where both the try block and the close method of the resource throw exceptions, which of the following is true about exception handling?
17In a try-finally block, what happens to a return statement inside the finally block?
18Which of the following is a best practice when creating a custom exception class?
19Given the following assertion: assert age >= 0 : "Age must be non-negative"; When is it appropriate to use assertions?
20Which of the following is a checked exception in Java?
21Consider the following code: public void process() throws Exception { try { riskyMethod(); } catch (IOException | SQLException e) { throw e; } } Assuming riskyMethod() declares both IOException and SQLException, what is the result?
22Given an exception chain where a custom exception is created with a cause, which method is used to set the cause after construction?
23Which TWO statements about try-with-resources are true? (Choose two.)
24Which TWO statements about creating custom exceptions are correct? (Choose two.)
25Which THREE statements about exception handling are true? (Choose three.)
26Given the exhibit showing a compilation error at line 5 of Test.java, which of the following code fragments could be at that line?
27Given the exhibit showing output from a program that uses try-with-resources, which of the following best describes the program?
28Given the code in the exhibit, which of the following is true about this custom exception?
29A 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?
30A method catches multiple exceptions using a multi-catch clause. Which statement about the exceptions in a multi-catch clause is correct?
31Which of the following is a best practice when designing custom exception classes?
32Given the following code snippet inside a method: try { // risky code } catch (IOException | SQLException e) { // handle } What is the implicit type of the exception variable 'e' in the catch block?
33What happens when a finally block throws an exception?
34Consider try-with-resources where resource1 is opened first, then resource2. During closing, both throw exceptions. Which exception is propagated to the caller?
35A developer wants to ensure that a block of code always executes regardless of whether an exception occurs or not, and that any exception thrown in the block is not swallowed. Which construct should be used?
36Which of the following is a checked exception in Java?
37Given a method that throws IOException, SQLException, and TimeoutException, a developer writes a catch block that rethrows the exception. Using Java 17, which exception types can the catch block declare in its throws clause if the rethrown exception is not modified?
38Which TWO statements about try-with-resources are correct? (Choose two.)
39Which THREE practices are recommended for effective exception handling? (Choose three.)
40Which TWO of the following are unchecked exceptions? (Choose two.)
41In the exhibit, if an IOException occurs during closing of both resources, which resource's close exception is returned by e.getSuppressed()?
42What is the result of executing the code in the exhibit?
43Your team manages a high-throughput financial transaction system running on Java 17. Recently, the application experiences intermittent slowdowns and increased CPU usage during peak hours. Monitoring reveals that exception handling code is invoked frequently due to validation errors in incoming data. The system uses a central exception handler that logs every exception and throws a custom ApplicationException. In many places, the code catches generic Exception and rethrows the custom exception after logging. Additionally, method signatures include throws Exception. The team wants to improve performance and maintainability without changing the external behavior significantly. Which course of action best addresses the performance and maintainability issues?
44A Java application uses a custom resource class implementing AutoCloseable. The close() method throws a checked exception. In a try-with-resources block, if both the try block and the close() method throw exceptions, which exception is propagated to the caller? Assume the resource is declared in try-with-resources.
45Which TWO are valid multi-catch statements in Java 17? (Choose two.)
46You are developing a batch processing application that reads records from a CSV file and parses each row into an integer ID. The reading method readNextRecord() returns a String and can throw IOException and NumberFormatException. The method processID(int id) processes the ID. The entire process runs in a for loop over 10,000 records. The requirement is that if any record fails (either due to file read error or parsing), the loop must continue to the next record, but the exception must be logged for later review. Which approach best achieves this requirement?
47A company has a service layer with a method performOperation() that originally declared throws BaseException (a checked exception). Several client methods call performOperation() and catch BaseException, wrapping it in a RuntimeException for propagation. After a system upgrade, the implementation of performOperation() now explicitly throws two new checked exceptions: SubException1 and SubException2, both of which extend BaseException. The client methods must continue to compile without modifying their catch signatures, and they must still handle the new exceptions appropriately. What is the best way to modify the client methods?
48Which two statements about multi-catch blocks are correct?
49A financial trading application uses Java 17 and processes millions of transactions per second. It uses a custom checked exception `TradeException extends Exception` for business rule violations. Recently, the transaction processing service began throwing a `RuntimeException` that wraps a `TradeException`, but the error logs only show the wrapper's message and stack trace, missing the original `TradeException` details. The logging framework prints the exception and its cause chain. The development team needs to ensure that the original `TradeException` message and stack trace are always logged. What is the most appropriate course of action?
The Handling Exceptions domain covers the key concepts tested in this area of the 1Z0-829 exam blueprint published by Oracle. Courseiva provides free domain-focused practice, mock exams, missed-question review, and readiness tracking across all 1Z0-829 domains — no account required.
The Courseiva 1Z0-829 question bank contains 49 questions in the Handling Exceptions domain. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the Handling Exceptions domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included