Courseiva
Working with Streams and Lambda ExpressionsmediumMultiple ChoiceObjective-mapped

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

Exhibit

List<Integer> numbers = List.of(10, 20, 30, 40, 50);
Optional<Integer> result = numbers.stream()
    .filter(n -> n > 100)
    .findFirst();
System.out.println(result.orElse(-1));

Refer to the exhibit. What is the output?

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

-1

The filter n > 100 yields an empty stream. findFirst returns an empty Optional. orElse(-1) returns -1.

Answer analysis

Option-by-option breakdown

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

  • 10

    Why it's wrong here

    Incorrect; no element satisfies condition.

  • null

    Why it's wrong here

    orElse returns -1, not null.

  • -1

    Why this is correct

    Correct.

  • Optional.empty

    Why it's wrong here

    Incorrect; the code prints -1, not the Optional.

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.