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

19
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
Full question →

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

Question 2hardmulti select
Full question →

Which TWO statements about lambda expressions are true? (Choose two.) 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 3hardmulti select
Full question →

Which THREE of the following are true about the Optional class? (Choose three.)

Question 4hardmultiple choice
Full question →

Given the following switch statement:

```java

int x = 2;

switch (x) { default: System.out.print("default "); case 1: System.out.print("1 "); case 2: System.out.print("2 "); case 3: System.out.print("3 "); break; case 4: System.out.print("4 ");

}

```

What is the output?

Question 5hardmultiple choice
Full question →

Which of the following will compile without error and produce an unmodifiable list containing three elements?

Question 6hardmultiple choice
Full question →

Given: Map<String, Integer> map = new HashMap<>(); map.put("x", 10); map.put("y", 20); map.computeIfAbsent("x", k -> 30); map.computeIfPresent("z", (k,v) -> 40); System.out.println(map); What is the output?

Question 7hardmulti select
Full question →

Which THREE statements are true about loops in Java?

Question 8hardmultiple choice
Full question →

A team is developing a large enterprise application using Java 17. The application consists of multiple modules: core (provides logging and configuration), services (business logic), and web (REST endpoints). The modules are packaged as separate JAR files and deployed on a server. During runtime, the web module throws a java.lang.ClassNotFoundException for a class that is part of the core module. The core module's module-info.java exports the package containing the missing class. The web module's module-info.java requires core. However, the services module also needs the same class but uses a different version of it, causing conflicts. The team decides to use the class path for the conflicting package and the module path for the rest. They add the conflicting JAR to the class path and keep the other JARs on the module path. After this change, the web module still cannot find the class, but the services module works fine. What is the most likely cause of the issue?

Question 9hardmultiple choice
Full question →

Given the following code:

```java outer:

for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if (i == 1) {

continue outer;

}

System.out.print(i + " " + j + " ");

}
}

```

What is the output?

Question 10hardmulti select
Full question →

Which TWO statements are true about the sealed class feature in Java 17?

Question 11hardmulti select
Full question →

Which TWO statements are true about the java.time.Duration class? (Choose two.)

Question 12hardmulti select
Full question →

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

Question 13hardmultiple choice
Full question →

Given: ZonedDateTime zdt = ZonedDateTime.of(2024, 3, 10, 2, 30, 0, 0, ZoneId.of("America/New_York")); In the US, on March 10, 2024, clocks spring forward at 2:00 AM to 3:00 AM. What is the output of System.out.println(zdt);?

Question 14hardmultiple choice
Full question →

Given a requirement to efficiently copy a large file (over 2 GB) from one path to another, which approach is most appropriate for Java NIO.2?

Question 15hardmultiple choice
Full question →

A serialized object has an explicitly declared serialVersionUID of 123L. After a code change, a new field is added to the class but the serialVersionUID is left unchanged. What happens when deserializing an old stream?

Question 16hardmultiple choice
Full question →

Refer to the exhibit. What is the result?

Exhibit

// File: com/example/Outer.java
public class Outer {
    private int x = 10;
    
    class Inner {
        public void printX() {
            System.out.println(x);
        }
    }
    
    public static void main(String[] args) {
        Outer outer = new Outer();
        Outer.Inner inner = outer.new Inner();
        inner.printX();
    }
}
Question 17hardmultiple choice
Full question →

Which change fixes the exception?

Exhibit

Refer to the exhibit.

```
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
    at LoopExample.main(LoopExample.java:5)
```

Source code of LoopExample.java:

```java
1: public class LoopExample {
2:     public static void main(String[] args) {
3:         int[] arr = {1,2,3};
4:         for (int i = 0; i <= arr.length; i++) {
5:             System.out.println(arr[i]);
6:         }
7:     }
8: }
```
Question 18hardmultiple choice
Full question →

A company runs a Java 17 microservice that processes real-time financial transactions. The application receives a large number of transactions per second, each with a timestamp, amount, and type. The current implementation uses a sequential stream to filter and aggregate transactions into a Map<TransactionType, DoubleSummaryStatistics>. The team observes high latency and CPU spikes during peak loads. They suspect the stream pipeline is inefficient. The pipeline code is:

Map<TransactionType, DoubleSummaryStatistics> stats = transactions.stream() .filter(t -> t.getTimestamp().isAfter(Instant.now().minusSeconds(60))) .collect(Collectors.groupingBy(Transaction::getType, Collectors.summarizingDouble(Transaction::getAmount)));

The transactions list is an ArrayList that is frequently modified by other threads (adding new transactions). The system has multiple CPU cores available. Which of the following changes is the MOST effective way to improve performance while maintaining correctness?

Question 19hardmultiple choice
Full question →

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?

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.