nerdexam
Oracle

1Z0-809 · Question #38

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…

The correct answer is C. 4:60. You've hit your session limit · resets 5:20pm (America/New_York)

Question

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 products = new ArrayList (Arrays.asList(new Product(1, 10), new Product (2, 30), new Product (2, 30))); Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {p1.price+=p2.price; p1.id=p1.id+p2.id; return p1; }); products.add(p); products.stream().parallel() .reduce((p1, p2) -> p1.price > p2.price ? p1 : p2) .ifPresent(System.out::println); What is the result?

Options

  • A2:30
  • B4:0
  • C4:60
  • D6:60
  • EThe program prints nothing.

How the community answered

(41 responses)
  • A
    10% (4)
  • B
    2% (1)
  • C
    80% (33)
  • D
    2% (1)
  • E
    5% (2)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice