exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 163 discussion

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

Given:
public class Product {
int id; int price;
public Product (int id, int price) {
this.id = id;
this.price = price;
}
Public String toString () { return id + ":" + price;)
}
and the code fragment:
List<Product> products = new ArrayList <> (Arrays.asList(new Product(1, 10), new Product (2, 30), new Product (3, 20));
Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> { p1.price+=p2.price; return new Product (p1.id, p1.price);}); products.add(p); products.stream().parallel()
.reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)
.ifPresent(System.out: :println);
What is the result?

  • A. 4:60
  • B. 2:30
  • C. 4:60 2:30 3:20 1:10
  • D. 4:0
  • E. The program prints nothing
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
Abdullah_Rahahleah
Highly Voted 3 years, 7 months ago
Answer is A List<Product> products = new ArrayList<>(Arrays.asList(new Product(1, 10), new Product (2, 30), new Product (3, 20))); Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> { p1.price+=p2.price; return new Product (p1.id, p1.price);}); System.out.println(p); products.add(p); products.stream().parallel().reduce( (p1, p2) -> p1.price > p2.price ? p1 : p2).ifPresent(System.out::println);
upvoted 6 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 1 week ago
A is the answer
upvoted 1 times
...
steefaand
5 months, 1 week ago
Selected Answer: A
Answer is A assuming typos are corrected.
upvoted 1 times
...
duydn
10 months ago
Selected Answer: A
A is correct
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Another question: if the List<Product> like this-> List<Product> products = Arrays.asList(new Product(1, 10), new Product (2, 30), new Product (3, 20); And: products.add(p); Answer is compile error.
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is A.
upvoted 1 times
...
Svetleto13
3 years, 2 months ago
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