Courseiva
Working with Streams and Lambda ExpressionshardMultiple ChoiceObjective-mapped

1Z0-829 Working with Streams and Lambda Expressions Practice Question

A team is implementing a parallel stream to process a large dataset. They notice that the operation is slower than expected. Which change is most likely to improve performance?

⚠ Common exam trap

It's easy for candidates to assume more threads (Option C) or switching to sequential (Option A) will fix performance, overlooking that the root cause is usually an inefficiently splittable source or non-associative/stateful operations, which are the key factors the exam tests for parallel stream optimization.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Ensure the stream source is an ArrayList and the operation is stateless and associative.

Parallel stream performance depends on the stream source being efficiently splittable (like an ArrayList, which has O(1) random access and can be split evenly) and the operation being stateless and associative to avoid synchronization overhead and ensure correct results. A poorly splittable source (e.g., LinkedList) or stateful operations can cause contention and reduce parallelism gains.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Use a sequential stream.

    Why it's wrong here

    A is wrong: sequential may be slower for large data sets.

  • Use a custom Collector instead of reduce.

    Why it's wrong here

    C is wrong: custom Collector does not inherently improve parallel performance.

  • Increase the parallelism level by setting -Djava.util.concurrent.ForkJoinPool.common.parallelism=100.

    Why it's wrong here

    B is wrong: too many threads can cause overhead and contention.

  • Ensure the stream source is an ArrayList and the operation is stateless and associative.

    Why this is correct

    D is correct: ArrayList splits well, and stateless/associative operations reduce merge cost.

About these practice questions

This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.