ProgrammingHardGATE CS · TCS NQT Prime · Product Company SDE

Which java.util.function functional interface best fits a lambda that takes one argument of type T and returns a boolean?

  1. A. Predicate<T>
  2. B. Consumer<T>
  3. C. Supplier<T>
  4. D. Function<T, R>

Correct answer: A. Predicate<T>

Predicate<T> is specifically defined with a single abstract method `boolean test(T t)`, matching a one-argument, boolean-returning lambda exactly.

More OOP with C++ and Java questions

Exams that ask this topic