Back to Oracle Certified Professional Java SE 17 Developer 1Z0-829 questions

Scenario-based practice

Hard Difficulty Questions

Practise Oracle Certified Professional Java SE 17 Developer 1Z0-829 practice questions — original exam-style scenarios covering every exam domain, with detailed explanations, wrong-answer analysis, and common exam traps.

20
scenario questions
1Z0-829
exam code
Oracle
vendor

Scenario guide

How to approach hard difficulty questions

These are the questions most candidates get wrong. They require connecting multiple concepts, reading tricky output, or knowing edge-case behaviour that isn't on most study cards. Practising them trains you to operate under uncertainty — a necessary skill on the real exam.

Quick answer

Hard Difficulty Questions 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.

Related practice questions

Related 1Z0-829 topic practice pages

Scenario questions usually connect to one or more exam topics. Use these links to review the underlying concepts behind the scenario.

Practice set

Practice scenarios

Question 1hardmultiple choice
Read the full NAT/PAT explanation →

A financial application uses Java SE 17 with a custom date format. The requirement is to parse strings like "2023-12-31T23:59:59.999Z" into an Instant. The existing code uses SimpleDateFormat with pattern "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" and then calls parse(). It works fine in single-threaded testing, but in production under load, intermittent parsing failures occur with DateTimeParseException or wrong values. The application is multi-threaded and reuses the same formatter instance. Which single change should be made to fix the issue while maintaining performance?

Question 2hardmulti select
Full question →

Which THREE statements are true about the java.util.Collection and java.util.stream.Stream APIs? (Choose three.)

Question 3hardmultiple choice
Full question →

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

Exhibit

Refer to the exhibit.
```
List<String> list = new ArrayList<>(List.of("A", "B", "C"));
for (String s : list) {
    if (s.equals("B")) {
        list.remove(s);
    }
}
System.out.println(list);
```
Question 4hardmultiple choice
Read the full NAT/PAT explanation →

A Java 17 application is deployed on a server. The application uses modules but one required module is missing from the module path. Which exception will be thrown at startup?

Question 5hardmulti select
Full question →

Which THREE are valid ways to package a Java 17 application for distribution? (Choose three.)

Question 6hardmulti select
Full question →

Which TWO are correct about parallel streams in Java? (Choose TWO.)

Question 7hardmultiple choice
Full question →

A developer needs to parse the string "2023-12-31T23:59:60Z" (a leap second) into a java.time.Instant. Which statement is true?

Question 8hardmultiple choice
Full question →

A method contains a try-with-resources statement that uses two resources: a FileInputStream and a BufferedInputStream. The FileInputStream constructor throws a FileNotFoundException. Which statement about resource closing is true?

Question 9hardmulti select
Full question →

Which THREE statements are true about loops in Java?

Question 10hardmulti select
Full question →

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

Question 11hardmulti select
Full question →

Which TWO are true about the PriorityQueue class?

Question 12hardmultiple choice
Full question →

What is the cause of the ClassCastException?

Exhibit

Refer to the exhibit.

Error log:
Exception in thread "main" java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String
    at com.example.Cache.get(Cache.java:12)
    at com.example.Main.main(Main.java:10)

Source code:
public class Cache {
    private Map<String, Object> store = new HashMap<>();
    public <T> T get(String key, Class<T> type) {
        Object value = store.get(key);
        return type.cast(value);
    }
}

public class Main {
    public static void main(String[] args) {
        Cache cache = new Cache();
        cache.store.put("age", 30);
        String age = cache.get("age", String.class);
        System.out.println(age);
    }
}
Question 13hardmultiple choice
Full question →

Given: TreeSet<Integer> ts = new TreeSet<>(Comparator.reverseOrder()); ts.add(10); ts.add(5); ts.add(20); ts.add(15); System.out.println(ts.first()); What is the result?

Question 14hardmulti select
Full question →

Which THREE statements about lambda expressions are true? (Choose three.) A. A lambda expression can be assigned to a functional interface variable. B. A lambda expression can access final or effectively final local variables. C. A lambda expression can throw any checked exception. D. A lambda expression can be used to create an instance of an abstract class. E. A lambda expression can be used to implement multiple abstract methods.

Question 15hardmulti select
Full question →

Which TWO statements about the Stream API are correct? (Choose two.) A. A stream can be traversed multiple times. B. The peek() method is an intermediate operation. C. The findFirst() method returns an Optional. D. The collect() method is an intermediate operation. E. The map() method returns a stream of the same type.

Question 16hardmultiple choice
Full question →

A developer is designing a service that processes multiple files concurrently. To avoid resource leaks, which practice is essential?

Question 17hardmultiple choice
Full question →

An application must read a configuration file that is updated frequently by another process. The developer wants to avoid stale data and minimize I/O operations. Which approach is best?

Question 18hardmulti select
Full question →

Which THREE are valid ways to read the contents of a text file into a String in Java?

Question 19hardmultiple choice
Full question →

What is the output of the program?

Exhibit

Refer to the exhibit.

public class LoopTest {
    public static void main(String[] args) {
        outer:
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i + j > 3) {
                    break outer;
                }
                System.out.print(i + j + " ");
            }
        }
    }
}
Question 20hardmulti select
Full question →

Which TWO statements about Java serialization are true?

These 1Z0-829 practice questions are part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style 1Z0-829 questions with detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics.