nerdexam
Oracle

1Z0-819 · Question #100

1Z0-819 Question #100: Real Exam Question with Answer & Explanation

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

Question

A bookstore's sales are represented by a list of Sale objects populated with the name of the customer and the books they purchased. public class Sale { String customer; private List<Book> items; /* constructor, setters and getters not shown */ } public class Book { private String name; private double price; /* constructor, setters and getters not shown */ } Given a list of Sale objects, lList, which code fragment creates a list of total sales for each customer in ascending order?

Options

  • AlList.stream() .collect(groupingBy(Sale::getCustomer, TreeMap::new, summingDouble(sale -> sale.getItems().stream().mapToDouble(Book::getPrice).sum()))); .entrySet().stream().sorted(Map.Entry.comparingByValue()) .collect(mapping(Entry::getKey, toList()));
  • BlList.stream() .collect(groupingBy(Sale::getCustomer, summingDouble(sale -> sale.getItems().stream().mapToDouble(Book::getPrice).sum()))); .entrySet().stream().sorted(Map.Entry.comparingByValue()) .collect(mapping(Entry::getKey, toList()));
  • ClList.stream() .collect(groupingBy(Sale::getCustomer, summingDouble(sale -> sale.getItems().stream().mapToDouble(Book::getPrice).sum()))); .entrySet().stream().sorted(Map.Entry.comparingByValue()) .collect(mapping(Entry::getKey, toList()));
  • DlList.stream() .collect(groupingBy(Sale::getCustomer, summingDouble(sale -> sale.getItems().stream().mapToDouble(Book::getPrice).sum()))); .entrySet().stream().sorted(Map.Entry.comparingByValue()) .collect(mapping(Entry::getKey, toList()));

Unlock 1Z0-819 to see the answer

You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 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.

Full 1Z0-819 Practice