Courseiva
Working with Arrays and CollectionsmediumMultiple ChoiceObjective-mapped

1Z0-829 Working with Arrays and Collections Practice Question

Exhibit

Refer to the exhibit.
List<String> list = new ArrayList<>(List.of("a","b","c"));
list.removeIf(s -> s.equals("b"));
System.out.println(list);

What is the output of the above code?

⚠ Common exam trap

It's easy for candidates to confuse `remove(Object)` with `remove(int index)` and think the code removes the element at index 1 (which would be "b" as well), but the correct understanding is that `remove(Object)` removes by value, not by index.

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

[a, c]

The code uses `List.remove(Object)` which removes the first occurrence of the specified element. After removing "b" from the list [a, b, c], the list becomes [a, c]. Option B is correct because the output is [a, c].

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, b]

    Why it's wrong here

    Incorrect: only "c" would remain if "a" were removed.

  • [a, c]

    Why this is correct

    Correct: "b" is removed, leaving a and c.

  • [a, b, c]

    Why it's wrong here

    Incorrect: "b" is removed.

  • [b, c]

    Why it's wrong here

    Incorrect: "a" should remain.

  • Compilation fails

    Why it's wrong here

    The code compiles and runs successfully.

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.