exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 87 discussion

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

Given:
and the code fragment:

Which modification enables the code fragment to print Speaker?

  • A. Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter (p -> p.ProductFilter.test (p))
  • B. Replace line n1 with: public static boolean isAvailable (Product p) {
  • C. Replace line n2 with: .filter (p -> p.ProductFilter: :isAvailable (p))
  • D. Replace line n2 with: .filter (p -> Product: :ProductFilter: :isAvailable ())
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
asdfjhfgjuaDCV
4 months, 3 weeks ago
B is the correct answer
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: B
B, since you can't call nonstatic method from static context
upvoted 1 times
...
push05
6 months, 2 weeks ago
import java.util.Arrays; import java.util.List; class Product { String name; int qty; public String toString(){ return name; } public Product(String name, int qty) { this.name = name; this.qty = qty; } static class ProductFilter { public static boolean isAvailable(Product p) { // line nl return p.qty >= 10; } public static void main (String [] args) { List<Product> products = Arrays.asList( new Product("MotherBoard", 5), new Product("Speaker", 20)) ; products.stream() .filter(Product.ProductFilter::isAvailable) // line n2 .forEach(p -> System.out.println(p)); } } }
upvoted 1 times
...
Svetleto13
3 years, 3 months ago
B,tested
upvoted 4 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