QuestionQ79

Working with Selected Classes from the Java API

Given these code fragments:

Question Image

Which code fragment, when inserted at line n1, causes the code to print Hank?

  • A
  • B
  • C
  • D
Explanation

Predicate<Person> requires a lambda compatible with boolean test(Person). The inferred parameter lambda p -> p.getAge() > 40 is valid and evaluates to true for Hank, whose age is 45, so Hank is printed.

Community Discussion

No comments yet. Be the first to start the discussion!