exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 183 discussion

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

Given:



What is the output?

  • A. 30
  • B. 35
  • C. 41
  • D. 46
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
6 months, 1 week ago
Selected Answer: A
persons.stream() .mapToInt(Person::getAge) .filter(p->p<20) .reduce(0, (a,b)->a+b); Here the order of operations is not optimal The main operations in a Stream pipeline and the order in which they occur are: filter sorted map collect IntStream mapToInt(ToIntFunction<? super T> mapper) ToIntFuncion f = (Person x) -> x.getAge(); or method reference Person::getAge Stream<T> filter(Predicate<T> predicate) Predicate predicate = p->p<20 int reduce(int identity, IntBinaryOperator op) IntBinarytOperator<T> = (a,b) -> a+b
upvoted 2 times
...
d7bb0b2
6 months, 4 weeks ago
Selected Answer: A
predicated filter is < 20 so that elements match with condition, sum 18 + 12 => 20
upvoted 2 times
d7bb0b2
6 months, 4 weeks ago
correct 30
upvoted 1 times
...
...
d7bb0b2
7 months ago
A is correct is a simple sum for all age that match with the condition. reduce begin in 0 and sum all elements
upvoted 1 times
...
Ashan_Ozlov
7 months, 1 week ago
the correct answer is A, tested
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