1Z0-829 Working with Streams and Lambda Expressions Practice Question
Which two statements about the Stream API are true? (Choose two.)
⚠ Common exam trap
Oracle Java certification exams often test the distinction between intermediate and terminal operations. The trap here is that candidates confuse `flatMap()` (intermediate) with a terminal operation or assume `collect()` is intermediate because it doesn't produce a single value like `reduce()`, but it is terminal because it consumes the stream.
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
✓
The 'reduce()' operation can produce a result of a different type than the stream elements.
The `reduce()` operation in the Stream API uses a combiner function that can transform the stream elements into an accumulated result of a different type. For example, `stream.reduce(0, (sum, i) -> sum + i, Integer::sum)` returns an `Integer` from an `IntStream`, or you can reduce a `Stream<String>` to a `StringBuilder`. This is explicitly allowed by the `reduce(U identity, BiFunction<U,? super T,U> accumulator, BinaryOperator<U> combiner)` signature.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The 'reduce()' operation can produce a result of a different type than the stream elements.
Why this is correct
The `reduce()` operation can produce a result of a different type than the stream elements. For example, `stream.reduce(0, (sum, i) -> sum + i, Integer::sum)` reduces an `IntStream` to an `Integer`.
- ✗
The 'flatMap()' operation is a terminal operation.
Why it's wrong here
The `flatMap()` operation is an intermediate operation, not a terminal operation. It transforms each element into a stream and then flattens them.
- ✓
The 'findFirst()' operation is a short-circuiting terminal operation.
Why this is correct
The `findFirst()` operation is a short-circuiting terminal operation. It returns an `Optional` describing the first element of the stream, and it can terminate early if a match is found.
- ✗
The 'collect()' operation is an intermediate operation.
Why it's wrong here
The `collect()` operation is a terminal operation, not an intermediate one. It consumes the stream and accumulates elements into a mutable container.
- ✗
Streams can be reused after a terminal operation.
Why it's wrong here
Streams cannot be reused after a terminal operation. Attempting to perform another operation on a consumed stream throws an `IllegalStateException`.
Go deeper
Related to this question
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 →
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.