Oracle
1Z0-819 · Question #192
Given: List<Integer> numbers = List.of(5, 3, 0, 8, 1, 9, 5, 7, 6, 4); int sum = numbers.stream().reduce(0, (n, m) -> n + m); // line 1 You want to make the reduction operation parallelized. Which…
The correct answer is A. Replace line 1 with int sum = numbers. stream (). Interate (). (a -> a+1. Reduce (0, (n,m) -> n+m). See the full explanation below for the reasoning.
Question
Given:
List<Integer> numbers = List.of(5, 3, 0, 8, 1, 9, 5, 7, 6, 4); int sum = numbers.stream().reduce(0, (n, m) -> n + m); // line 1 You want to make the reduction operation parallelized. Which two modifications should you make?Options
- AReplace line 1 with int sum = numbers. stream (). Interate (). (a -> a+1. Reduce (0, (n,m) -> n+m);
- BReplace line 1with int sum = numbers. ParallelStream (). Reduce (0, (n,m) -> n+m);
- CReplace line 1with int sum = numbers. stream (). mapToInt (a -> a.Reduce (0, (n,m) -> n+m);
- DReplace line 1with int sum = number. stream (). flatMap (a -> a).reduce (0, (n,m) -> n+m);
- EReplace line 1with int sum = number.stream. parallel (). Reduce (0, (n,m) -> n+m);
How the community answered
(31 responses)- A81% (25)
- C6% (2)
- D10% (3)
- E3% (1)
Community Discussion
No community discussion yet for this question.