Courseiva
Working with Streams and Lambda ExpressionseasyMultiple SelectObjective-mapped

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

Which two statements are true about the peek method of the Stream API? (Choose two.)

⚠ Common exam trap

Test-takers frequently confuse `peek` with `map`, thinking `peek` can modify or transform elements, when in fact `peek` only observes and returns the same elements unchanged.

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

It is primarily used for debugging purposes.

The `peek` method is designed as a debugging aid to observe elements as they flow through a stream pipeline. It performs the provided action on each element without modifying them, making it ideal for logging or printing intermediate states.

Answer analysis

Option-by-option breakdown

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

  • It is primarily used for debugging purposes.

    Why this is correct

    peek is intended to aid in debugging by allowing observation of elements as they pass through the pipeline.

  • It is an intermediate operation.

    Why this is correct

    peek returns a stream consisting of the elements of the original stream, performing the provided action on each element.

  • It can be used to modify the elements of the stream.

    Why it's wrong here

    peek is designed for debugging; modifying state is discouraged and can lead to undefined behavior.

  • It is a terminal operation.

    Why it's wrong here

    peek is not a terminal operation; it must be followed by a terminal operation to produce a result.

  • It can be used to transform the elements into a new value.

    Why it's wrong here

    Transformation is the role of map, not peek.

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.