Courseiva
Working with Streams and Lambda ExpressionsmediumMultiple ChoiceObjective-mapped

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

A developer writes: list.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); What is the result type and content?

⚠ Common exam trap

The trap is that candidates may focus on individual correct statements and overlook that option A combines both B and C. Recognizing that the result is both a Map<T, Long> and a frequency map is key.

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

Both B and C.

Option A, 'Both B and C,' is the correct answer because both statements accurately describe the result. Collectors.groupingBy with Function.identity() and Collectors.counting() produces a Map<T, Long> (where T is the element type) containing the frequency of each element, which can also be described as a Map<Object, Long> with occurrence counts. Options B and C individually are true but incomplete; the question expects selection of the combination. Option D is incorrect because groupingBy without a map supplier returns a HashMap, not a ConcurrentMap.

Answer analysis

Option-by-option breakdown

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

  • Both B and C.

    Why this is correct

    This option is self-referential and meaningless; it does not provide a valid description of the result.

  • Map<T, Long> where T is element type.

    Why it's wrong here

    Correct. The stream elements are of type T, and groupingBy with identity produces a Map<T, Long>.

  • Map<Object, Long> with number of occurrences of each element.

    Why it's wrong here

    Correct. The map stores each distinct element as a key and its count as a Long value.

  • A ConcurrentMap.

    Why it's wrong here

    Incorrect. The default map type is HashMap, not ConcurrentMap.

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.