Courseiva
Working with Arrays and CollectionshardMultiple SelectObjective-mapped

1Z0-829 Working with Arrays and Collections Practice Question

Which THREE statements are true about the java.util.Collection and java.util.stream.Stream APIs? (Choose three.)

⚠ Common exam trap

It's easy for candidates to assume forEach() always preserves order regardless of stream type, but the Stream API explicitly states that forEach() does not guarantee encounter order for parallel streams, unlike forEachOrdered().

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 Stream.forEach() operation processes elements in the encounter order of the stream only for sequential streams.

The Stream.forEach() operation respects the encounter order of the stream only for sequential streams. For parallel streams, the order is not guaranteed unless the stream is explicitly forced to be sequential or uses forEachOrdered(). This behavior is defined in the Stream API specification.

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 Collection.forEach() method is inherited from the Collection interface.

    Why it's wrong here

    It is inherited from Iterable.

  • The Stream.forEach() operation processes elements in the encounter order of the stream only for sequential streams.

    Why this is correct

    Parallel streams may process elements out of order.

  • The Collection interface inherits the stream() method from the Iterable interface.

    Why it's wrong here

    stream() is defined in Collection, not Iterable.

  • The Stream.toList() method returns an unmodifiable list.

    Why this is correct

    Since Java 16.

  • The Iterator interface provides a default method forEachRemaining(Consumer<? super E> action).

    Why this is correct

    Introduced in Java 8.

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 →

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.