1Z0-829 · topic practice

Handling Exceptions practice questions

Practise Oracle Certified Professional Java SE 17 Developer 1Z0-829 Handling Exceptions practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Handling Exceptions

What the exam tests

What to know about Handling Exceptions

Handling Exceptions questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Handling Exceptions exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Handling Exceptions questions

20 questions · select your answer, then reveal the explanation

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?

A 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?

Which TWO statements about the try-with-resources statement are correct? (Choose two.)

What is the result when the main method is executed?

Exhibit

Refer to the exhibit.

```
public class ExceptionDemo {
    public static void main(String[] args) {
        try {
            throw new RuntimeException("A");
        } catch (RuntimeException e) {
            throw new RuntimeException("B");
        } finally {
            throw new RuntimeException("C");
        }
    }
}
```

You 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?

Which TWO of the following are checked exceptions in Java?

Given the stack trace, which statement is true about the exception handling?

Exhibit

Refer to the exhibit.
```
Exception in thread "main" java.lang.RuntimeException: Error processing order
    at com.example.OrderService.process(OrderService.java:25)
    at com.example.OrderService.main(OrderService.java:10)
Caused by: java.sql.SQLException: Connection timeout
    at com.example.db.DatabaseConnection.connect(DatabaseConnection.java:15)
    at com.example.OrderService.process(OrderService.java:22)
    ... 1 more
```

You 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?

Which TWO statements about the try-with-resources statement are true? (Choose two.)

What is the output when the code is executed?

Exhibit

Refer to the exhibit.

public class Main {
    public static void main(String[] args) {
        try {
            int result = 10 / 0;
        } catch (ArithmeticException e) {
            System.out.println("Arithmetic");
            throw e;
        } catch (Exception e) {
            System.out.println("Exception");
        } finally {
            System.out.println("Finally");
        }
    }
}

You 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?

Order the steps to compile and run a simple Java program from the command line.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

Match each JDBC type to its corresponding Java type.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

String

int

long

boolean

java.sql.Timestamp

A method reads a file and throws IOException. Which of the following is the correct way to declare the method?

Consider the following code snippet:

try { // some code

} catch (IOException e) {

// handle

} catch (FileNotFoundException e) { // Line X

// handle

}

What will be the result?

Given 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?

In a try-finally block, what happens to a return statement inside the finally block?

Which of the following is a best practice when creating a custom exception class?

Given the following assertion: assert age >= 0 : "Age must be non-negative"; When is it appropriate to use assertions?

Which of the following is a checked exception in Java?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Handling Exceptions sessions

Start a Handling Exceptions only practice session

Every question in these sessions is drawn from the Handling Exceptions domain — nothing else.

Related practice questions

Related 1Z0-829 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the 1Z0-829 exam test about Handling Exceptions?
Handling Exceptions questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Handling Exceptions questions in a focused session?
Yes — the session launcher on this page draws every question from the Handling Exceptions domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other 1Z0-829 topics?
Use the topic links above to move to related areas, or go back to the 1Z0-829 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the 1Z0-829 exam covers. They are not copied from any real exam or dump site.