Courseiva
Working with Streams and Lambda ExpressionshardMultiple SelectObjective-mapped

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

Which TWO statements about the Stream API are correct? (Choose two.) A. A stream can be traversed multiple times. B. The peek() method is an intermediate operation. C. The findFirst() method returns an Optional. D. The collect() method is an intermediate operation. E. The map() method returns a stream of the same type.

⚠ Common exam trap

The main trap in this question is confusing intermediate and terminal operations. Candidates often mistake collect() as intermediate or think that peek() is terminal. Another trap is assuming streams can be reused, but they are single-use only.

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 peek() method is an intermediate operation.

The correct statements are B and C. Option B is correct because peek() is an intermediate operation that allows performing an action on each element without modifying the stream. Option C is correct because findFirst() returns an Optional describing the first element, or an empty Optional if the stream is empty. Option A is incorrect because a stream can only be consumed once; it cannot be traversed multiple times. Option D is incorrect because collect() is a terminal operation, not an intermediate operation. Option E is incorrect because map() can change the element type; for example, mapping a Stream<String> to Stream<Integer> is common.

Answer analysis

Option-by-option breakdown

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

  • A stream can be traversed multiple times.

    Why it's wrong here

    This statement is false. A stream can only be traversed once. Attempting to traverse it a second time throws an IllegalStateException.

  • The peek() method is an intermediate operation.

    Why this is correct

    This statement is true. peek() is an intermediate operation that returns the same stream elements after performing an action.

  • The findFirst() method returns an Optional.

    Why this is correct

    This statement is true. findFirst() returns an Optional containing the first element, or an empty Optional if the stream is empty.

  • The collect() method is an intermediate operation.

    Why it's wrong here

    This statement is false. collect() is a terminal operation; it consumes the stream and produces a result.

  • The map() method returns a stream of the same type.

    Why it's wrong here

    This statement is false. map() applies a function to each element and can change the element type; the resulting stream type is determined by the function's return type.

About these practice questions

Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.