Which statement is equivalent to line 1?

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);

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “Which statement is equivalent to line 1?

    1. 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.

      15
      1

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.