nerdexam
Oracle

1Z0-829 · Question #11

1Z0-829 Question #11: Real Exam Question with Answer & Explanation

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

Working with Streams and Lambda expressions

Question

Given: class Product { String name; double price; Product(String s, double d) { this.name = s; this.price = d; } } class ElectricProduct extends Product { ElectricProduct(String name, double price) { super(name, price); } } and the code fragment: List<Product> p = List.of( new ElectricProduct("CellPhone",100), new ElectricProduct("ToyCar",80), new ElectricProduct("Motor",150), new ElectricProduct("Fan",300) ); DoubleSummaryStatistics sts = p.stream().filter(a -> a instanceof ElectricProduct) .collect(Collectors.summarizingDouble(a -> a.price())); String s1 = p.stream().filter(a -> a instanceof Product) .collect(Collectors.mapping(p2 -> p2.name, Collectors.joining(", "))); System.out.println(sts.getMax()); System.out.println(s1); What is the result?

Options

  • A300.00
  • BCellPhone,ToyCar,Motor,Fan
  • C100.00, CellPhone,ToyCar,Motor,Fan
  • D400.00
  • ECellPhone,ToyCar

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 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.

Topics

#Streams & Collectors#Lambda expressions#DoubleSummaryStatistics#Polymorphism
Full 1Z0-829 Practice