1z0829 Java SE 17 Developer Free Practice Test — 30 Questions

30 questions · Full explanations · No account required

Free
Question 1 of 30

A team is developing a high-throughput data processing module in Java SE 17. They are using a parallel stream to process a large `List` named `sourceData`. The processing involves transforming each string and collecting them into a new `List`. However, during testing, they observe sporadic `ConcurrentModificationException` errors. The code snippet responsible for the processing is:

```java List sourceData = new ArrayList(Arrays.asList(\"a\", \"b\", \"c\", \"d\", \"e\")); // Assume another thread is concurrently adding elements to sourceData

List processedData = sourceData.parallelStream() .map(String::toUpperCase) .collect(Collectors.toList()); ```

Which of the following is the most probable underlying cause for the observed `ConcurrentModificationException`?

The default implementation of `Collectors.toList()` uses a mutable `ArrayList` internally, which is not designed for concurrent modification of the source collection during parallel stream processing.
The `parallelStream()` operation itself inherently introduces thread safety issues, regardless of the collector used.
Using `String::toUpperCase` on a `List` in a parallel stream will always lead to a `ConcurrentModificationException`.
`Collectors.toUnmodifiableList()` would have prevented this by ensuring immutability, indicating a flaw in the collector choice.

About the 1z0829 Java SE 17 Developer Certification

These free practice questions are designed to help you assess your readiness for the 1z0829 Java SE 17 Developer exam by Other. Each question comes with a detailed explanation to reinforce the correct concept. For a complete exam preparation experience with hundreds of questions, spaced-repetition study tools, and full exam simulations, explore our premium access.