nerdexam
Oracle

1Z0-829 · Question #27

1Z0-829 Question #27: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #27. The question stem and answer options stay visible for context.

Working with Streams and Lambda expressions

Question

Given: public class Test { public static void main(String[] args) { List<String> elements = Arrays.asList("car", "truck", "car", "bicycle", "car", "truck", "motorcycle"); Map<String, Long> outcome = elements.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting() ) ); System.out.println(outcome); } } What is the result?

Options

  • ABicycle=7, car=7, motorcycle=7, truck=7)
  • B3:bicycle, 0:car, 0motorcycle, 5:truck)
  • CBicycle, car, motorcycle, truck)
  • DBicycle=1, car=3, motorcycle=1, truck=2)
  • ECompilation fails.

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Collectors#groupingBy#Stream API#Functional interfaces
Full 1Z0-829 Practice
Given: public class Test { public static void main(String args) {... | 1Z0-829 Q#27 Answer | NerdExam