Courseiva
Working with Streams and Lambda ExpressionsmediumMultiple SelectObjective-mapped

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

Which THREE of the following are valid ways to create a Stream<String>? (Choose three.)

⚠ Common exam trap

It's easy for candidates to confuse `chars()` as returning a `Stream<Character>` or `Stream<String>`, when in fact it returns an `IntStream` of code points, and they may also mistakenly think `Stream` can be instantiated with `new` like a regular class.

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

Arrays.stream(new String[]{"a", "b"})

`Arrays.stream(T[])` returns a `Stream<T>` from an array. Passing `new String[]{"a", "b"}` creates a `Stream<String>` directly, as the method is overloaded for object arrays.

Answer analysis

Option-by-option breakdown

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

  • Arrays.stream(new String[]{"a", "b"})

    Why this is correct

    Arrays.stream for object arrays returns a Stream of the array elements.

  • Stream.of("a", "b")

    Why this is correct

    Stream.of with varargs creates a stream of the provided elements.

  • List.of("a", "b").stream()

    Why this is correct

    Collection.stream() is a standard way to obtain a stream.

  • "ab".chars()

    Why it's wrong here

    chars() returns an IntStream (primitive), not a Stream<String>.

  • new Stream<String>()

    Why it's wrong here

    Stream is an interface; cannot be instantiated directly.

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.