exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 165 discussion

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

Given the code fragment:



Which two code fragments, independently, replace line 1 to implement the equivalent reduce operation? (Choose two.)

  • A. Integer sum = data.map(a -> a).reduce((a, b) -> a+b);
  • B. OptionalInt value = data.mapToInt(a -> a).parallel().reduce(0, (a, b) -> a+b);
    Integer sum = value.getAsInt();
  • C. int s = 0;
    Integer sum = data.map(a -> a).reduce(0, (a-> a + s));
  • D. OptionalInt value = data.mapToInt(a -> a).parallel().reduce((a, b) -> a+b);
    Integer sum = value.getAsInt();
  • E. Integer sum = data.mapToInt(a -> a).reduce(0, (a,b)->a+b));
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
ASPushkin
5 months, 3 weeks ago
Selected Answer: DE
answer: DE A. not possible output is Optional B. - wrong output must int C. - wrong in reduce accumulator should have two parameters D. E. - correct
upvoted 1 times
...
d7bb0b2
6 months, 3 weeks ago
Selected Answer: BD
B, D AND E, ARE VALIDS. PARALLELL is valid in intstraeam()
upvoted 1 times
d7bb0b2
6 months, 3 weeks ago
SORRY : corrected D and E are correct, B is not valid reduce with acumulator parameter(first parameters before lambda) return an int NO optional int
upvoted 1 times
...
...
dilleman
10 months ago
Selected Answer: DE
Tested, D and E
upvoted 1 times
...
Ashan_Ozlov
10 months ago
Selected Answer: DE
Tested
upvoted 1 times
...
[Removed]
11 months, 1 week ago
Selected Answer: DE
Apparently the overloaded reduce method on an IntStream accepting an identifier as the first parameter, will return an INT. Whenever you use the one without an identifier it returns an OptionalInt
upvoted 1 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