Given:
and the code fragment:
Which two Map objects group all employees with a salary greater than 30 by neighborhood? (Choose two.)
Given:
and the code fragment:
Which two Map objects group all employees with a salary greater than 30 by neighborhood? (Choose two.)
To group all employees with a salary greater than 30 by neighborhood, the correct usage involves combining filtering and grouping functions. Option B successfully groups by the function "f" and then filters those that match the predicate "p". Option D effectively groups by neighborhood and then applies a filtering collector. Both options correctly implement filtering based on salary and grouping by neighborhood using the appropriate Collectors methods.
answer : B, D A - not correct Collectors.groupingBy(Function ... but here we have Collectors.groupingBy(Predicate C : not right static <T,K,A,D> Collector<T,?,Map<K,D>> groupingBy(Function<? super T,? extends K> classifier, Collector<? super T,A,D> downstream) So, downstream is a Collector We have : Employee::getNeighborhood() E: not correct it has syntax error at the end. both works - checked just one thing - roster.stream().collect() - doesn't work you should specify the Employee type like : Stream<Employee> s = roster.stream(); Map <Optional<String>, List <Employee>> r4 = s.collect(collector); remaining two are correct
Tested BD