1Z0-829 Working with Streams and Lambda Expressions Practice Question
A developer writes the following code using the Stream API:
List<String> list = List.of("a", "b", "c"); String result = list.stream().reduce("", (s1, s2) -> s1 + s2); System.out.println(result);
What is the output?
⚠ Common exam trap
Many candidates confuse the `reduce` overloads, mistakenly thinking that all `reduce` operations return an `Optional`, or they forget that the identity value is included in the accumulation, leading them to expect an `Optional` wrapper or a reversed order.
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
✓
abc
The `reduce` method with an identity value (`""`) and a binary operator (`(s1, s2) -> s1 + s2`) accumulates the stream elements in encounter order. Starting from the identity, it concatenates each element: `"" + "a" = "a"`, then `"a" + "b" = "ab"`, then `"ab" + "c" = "abc"`. The result is a `String`, not an `Optional`, because an identity is provided.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
abc
Why this is correct
Correct concatenation.
- ✗
a
Why it's wrong here
The identity is not ignored; all elements are combined.
- ✗
Optional[abc]
Why it's wrong here
reduce with identity returns a value, not Optional.
- ✗
cba
Why it's wrong here
Order is preserved as sequential stream.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.