QuestionQ25

Using Operators and Decision Constructs

Given this code fragment:

Question Image

Which snippet on line 9 prints true?

  • A Boolean s = p.apply(101); System.out.println(s);
  • B
  • D System.out.println(p.apply(100));
Explanation

A Predicate<Integer> is evaluated with test(Integer). The predicate returns true for 100 because 100 is even, so printing that result outputs true.

Community Discussion

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