exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 163 discussion

Actual exam question from Oracle's 1z0-819
Question #: 163
Topic #: 1
[All 1z0-819 Questions]

Given:



You want to make the reduction operation parallelized.

Which two modifications will accomplish this?

  • A. Replace line 1 with int sum = numbers.stream() .flatMap(a -> a).reduce (0, (n, m) -> n + m);.
  • B. Replace line 1 with int sum = numbers.stream().iterate (0, a -> a+1).reduce (0, (n, m) -> n + m)
  • C. Replace line 1 with int sum = numbers.parallel ().stream().reduce(0, (n, m) -> n + m)
  • D. Replace line 1 with int sum = numbers.parallelStream().reduce (0, (n, m) -> n + m);.
  • E. Replace line 1 with int sum = numbers.stream().parallel().reduce(0, (n, m) -> n + m)
Show Suggested Answer Hide Answer
Suggested Answer: DE 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
d7bb0b2
7 months, 4 weeks ago
D, E List is a collection uses a parallelStream() to gnerate a stream parallel E : Stream contains pararell method to generte. stream parallel
upvoted 1 times
...
[Removed]
11 months, 1 week ago
Selected Answer: DE
DE is correct
upvoted 1 times
...
Stavok
1 year ago
Selected Answer: DE
A List of Integer objects representing numbers is created and assigned to the numbers variable.A Stream is created from the numbers list using either the parallelStream() method or the stream().parallel() method chain. This creates a parallel stream that can process elements concurrently.The reduce() method is called on the parallel stream, passing in an initial value of 0 and a lambda expression that adds two numbers together. This method performs a reduction on the elements of the stream, using the provided identity value and an associative accumulation function.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago