Given:
Which statement is equivalent to line 1?
A. double totalSalary = list.stream().map(e -> e.getSalary() * ratio).reduce(bo).ifPresent (p -> p.doubleValue());
B. double totalSalary = list.stream().mapToDouble(e -> e.getSalary() * ratio).sum;
C. double totalSalary = list.stream().map(Employee::getSalary * ratio).reduce(bo).orElse(0.0);
D. double totalSalary = list.stream().mapToDouble(e -> e.getSalary() * ratio).reduce(starts, bo);
C is the correct answer.
B is the correct Answer.
D
It must be B (there is a typo at the end, there should be .sum()) but D is not correct because after mapToDouble, you can use reduce, but you have to have DoubleBinaryOperator as second input, which is not in this case.