Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

← Handling Exceptions practice sets

1Z0-829 Handling Exceptions • Complete Question Bank

1Z0-829 Handling Exceptions — All Questions With Answers

Complete 1Z0-829 Handling Exceptions question bank — all 0 questions with answers and detailed explanations.

49
Questions
Free
No signup
Certifications/1Z0-829/Practice Test/Handling Exceptions/All Questions
Question 1mediummultiple choice
Read the full Handling Exceptions 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?

Question 2easymultiple choice
Read the full Handling Exceptions explanation →

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?

Question 3hardmulti select
Read the full Handling Exceptions explanation →

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

Question 4mediummultiple choice
Read the full Handling Exceptions explanation →

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");
        }
    }
}
```
Question 5hardmultiple choice
Read the full Handling Exceptions explanation →

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?

Question 6mediummulti select
Read the full Handling Exceptions explanation →

Which TWO of the following are checked exceptions in Java?

Question 7hardmultiple choice
Read the full Handling Exceptions explanation →

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
```
Question 8easymultiple choice
Read the full Handling Exceptions explanation →

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?

Question 9easymulti select
Read the full Handling Exceptions explanation →

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

Question 10mediummultiple choice
Read the full Handling Exceptions explanation →

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");
        }
    }
}
Question 11hardmultiple choice
Read the full Handling Exceptions explanation →

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?

Question 12mediumdrag order
Read the full Handling Exceptions explanation →

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
Question 13mediummatching
Read the full Handling Exceptions explanation →

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

Question 14easymultiple choice
Read the full Handling Exceptions explanation →

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

Question 15mediummultiple choice
Read the full Handling Exceptions explanation →

Consider the following code snippet:

try { // some code

} catch (IOException e) {

// handle

} catch (FileNotFoundException e) { // Line X

// handle

}

What will be the result?

Question 16hardmultiple choice
Read the full Handling Exceptions explanation →

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?

Question 17easymultiple choice
Read the full Handling Exceptions explanation →

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

Question 18mediummultiple choice
Read the full Handling Exceptions explanation →

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

Question 19hardmultiple choice
Read the full Handling Exceptions explanation →

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

Question 20easymultiple choice
Read the full Handling Exceptions explanation →

Which of the following is a checked exception in Java?

Question 21mediummultiple choice
Read the full Handling Exceptions explanation →

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

Question 22hardmultiple choice
Read the full Handling Exceptions explanation →

Given an exception chain where a custom exception is created with a cause, which method is used to set the cause after construction?

Question 23mediummulti select
Read the full Handling Exceptions explanation →

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

Question 24hardmulti select
Read the full Handling Exceptions explanation →

Which TWO statements about creating custom exceptions are correct? (Choose two.)

Question 25easymulti select
Read the full Handling Exceptions explanation →

Which THREE statements about exception handling are true? (Choose three.)

Question 26mediummultiple choice
Read the full Handling Exceptions explanation →

Given the exhibit showing a compilation error at line 5 of Test.java, which of the following code fragments could be at that line?

Exhibit

Refer to the exhibit.

Compilation output:
Error: unreported exception java.io.IOException; must be caught or declared to be thrown
  at Test.main(Test.java:5)
Question 27hardmultiple choice
Read the full Handling Exceptions explanation →

Given the exhibit showing output from a program that uses try-with-resources, which of the following best describes the program?

Exhibit

Refer to the exhibit.

Execution output:
Exception in thread "main" java.io.IOException: IO error
	at Test.main(Test.java:10)
Suppressed: java.io.IOException: Close error
	at Test$MyResource.close(Test.java:20)
Question 28easymultiple choice
Read the full Handling Exceptions explanation →

Given the code in the exhibit, which of the following is true about this custom exception?

Exhibit

Refer to the exhibit.

public class CustomException extends RuntimeException {
    public CustomException(String message) {
        super(message);
    }
}

Usage:
throw new CustomException("Error");
Question 29mediummultiple choice
Read the full Handling Exceptions explanation →

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?

Question 30hardmultiple choice
Read the full Handling Exceptions explanation →

A method catches multiple exceptions using a multi-catch clause. Which statement about the exceptions in a multi-catch clause is correct?

Question 31easymultiple choice
Read the full Handling Exceptions explanation →

Which of the following is a best practice when designing custom exception classes?

Question 32mediummultiple choice
Read the full Handling Exceptions explanation →

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

Question 33easymultiple choice
Read the full Handling Exceptions explanation →

What happens when a finally block throws an exception?

Question 34hardmultiple choice
Read the full Handling Exceptions explanation →

Consider try-with-resources where resource1 is opened first, then resource2. During closing, both throw exceptions. Which exception is propagated to the caller?

Question 35mediummultiple choice
Read the full Handling Exceptions explanation →

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

Question 36easymultiple choice
Read the full Handling Exceptions explanation →

Which of the following is a checked exception in Java?

Question 37hardmultiple choice
Read the full Handling Exceptions explanation →

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

Question 38mediummulti select
Read the full Handling Exceptions explanation →

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

Question 39hardmulti select
Read the full Handling Exceptions explanation →

Which THREE practices are recommended for effective exception handling? (Choose three.)

Question 40easymulti select
Read the full Handling Exceptions explanation →

Which TWO of the following are unchecked exceptions? (Choose two.)

Question 41hardmultiple choice
Read the full Handling Exceptions explanation →

In the exhibit, if an IOException occurs during closing of both resources, which resource's close exception is returned by e.getSuppressed()?

Exhibit

Refer to the exhibit.

try (FileInputStream fis = new FileInputStream("file.txt");
     BufferedInputStream bis = new BufferedInputStream(fis)) {
    // read data
} catch (IOException e) {
    System.out.println(e.getMessage());
    Throwable[] suppressed = e.getSuppressed();
}
Question 42mediummultiple choice
Read the full Handling Exceptions explanation →

What is the result of executing the code in the exhibit?

Exhibit

Refer to the exhibit.

public class ExceptionDemo {
    public static void main(String[] args) {
        try {
            methodA();
        } catch (Exception e) {
            System.out.println("Caught in main: " + e.getClass().getSimpleName());
        }
    }
    static void methodA() throws IOException {
        try {
            throw new IOException();
        } catch (Exception e) {
            throw e;
        }
    }
}
Question 43hardmultiple choice
Read the full NAT/PAT explanation →

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

Question 44mediummultiple choice
Read the full Handling Exceptions explanation →

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

Question 45hardmulti select
Read the full Handling Exceptions explanation →

Which TWO are valid multi-catch statements in Java 17? (Choose two.)

Question 46easymultiple choice
Read the full Handling Exceptions explanation →

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

Question 47mediummultiple choice
Read the full NAT/PAT explanation →

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

Question 48mediummulti select
Read the full Handling Exceptions explanation →

Which two statements about multi-catch blocks are correct?

Question 49hardmultiple choice
Read the full Handling Exceptions explanation →

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

Practice tests

Scored 10-question sessions with instant feedback and explanations.

1Z0-829 Practice Test 1 — 10 Questions→1Z0-829 Practice Test 2 — 10 Questions→1Z0-829 Practice Test 3 — 10 Questions→1Z0-829 Practice Test 4 — 10 Questions→1Z0-829 Practice Test 5 — 10 Questions→1Z0-829 Practice Exam 1 — 20 Questions→1Z0-829 Practice Exam 2 — 20 Questions→1Z0-829 Practice Exam 3 — 20 Questions→1Z0-829 Practice Exam 4 — 20 Questions→Free 1Z0-829 Practice Test 1 — 30 Questions→Free 1Z0-829 Practice Test 2 — 30 Questions→Free 1Z0-829 Practice Test 3 — 30 Questions→1Z0-829 Practice Questions 1 — 50 Questions→1Z0-829 Practice Questions 2 — 50 Questions→1Z0-829 Exam Simulation 1 — 100 Questions→

Practice by domain

Each domain maps to a weighted exam section. Focus on the domain where you are weakest.

Handling Date, Time, Text, Numeric and Boolean ValuesControlling Program FlowUtilizing Java Object-Oriented ApproachHandling ExceptionsWorking with Arrays and CollectionsWorking with Streams and Lambda ExpressionsJava Platform Overview and PackagingJava I/O API and Securing Applications

Practice by scenario

Filter questions by type — troubleshooting, exhibit, drag-and-drop, PBQ, ACLs, OSPF, and more.

Browse scenarios→

Continue studying

All Handling Exceptions setsAll Handling Exceptions questions1Z0-829 Practice Hub