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, we need to use both the predicate to filter the employees and the function/method to group by neighborhood. The correct options are those that correctly implement these functionalities without syntax errors. 'A' uses the function 'f' to group and the predicate 'p' to filter while 'C' uses 'getNeighborhood' to group and the predicate 'p' to filter. Both of these implementations are correct and compile without issues.
If you think about it this makes sence without knowing too much about the exact syntax. A: We use the function f to group and the predicate p to filter. This is correct. B: We use the predicate p both to filter and group. This does not compile since groping does not take a predicate. C: We use the getNeighborhood-method to group and the predicate to filter. This is correct. D: We correctly use the predicate to filter but use both the function and the getNeighborhood to group and this method is already defined in the function. This does not look correct with double grouping on that method. E: This is a copy of C but with extra parentheses in the end and this does not compile.
Your explanation is brilliant! Thank you, dilleman!
correct answers are A and C
same as 210 answer: A, C
tested D uses function f() with Optional but left site uses directly String - not compiled
Correct are A and D Tested C and E does not compile because their provide a Map<String, List<Employee>> not Map<Optional<String>, List<employee>> B is not correct
Tested, A and C.
And maybe C - if we need two correct answers...
Tested: A.
A & B are correct
Answer: C