nerdexam
Oracle

1Z0-809 · Question #227

1Z0-809 Question #227: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #227. The question stem and answer options stay visible for context.

Question

Given the code fragments:
public class Product {
 String name;
 Integer price;
 Product(String name, Integer price) {
 this.name = name;
 this.price = price;
 }
 public void printVal() { System.out.print(name + " Price:" + price + " "); }
 public void setPrice(int price) { this.price = price; }
 public Integer getPrice() { return price; }
}
and
List<Product> li = Arrays.asList(new Product("TV", 1000), new Product("Refrigerator", 2000));
Consumer<Product> raise = e -> e.setPrice(e.getPrice() + 100);
li.forEach(raise);
li.forEach(Product::printVal);
What is the result?

Options

  • ATV Price :110 Refrigerator Price :2100
  • BA compilation error occurs.
  • CTV Price :1000 Refrigerator Price :2000
  • DThe program prints nothing.

Unlock 1Z0-809 to see the answer

You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Full 1Z0-809 Practice