Java OCA OCP Practice Question 1661

Question

Fill in the blanks:

In the Collection interface, the method removeIf() takes a ___, while the method forEach() takes a ___.

  • A. Function, Function
  • B. Predicate, Consumer
  • C. Predicate, Function
  • D. Predicate, UnaryOperator


B.

Note

The removeIf() method requires a Predicate since it operates on a boolean result, making Option A incorrect.

The forEach() method takes a Consumer and does not return any data, making Option B correct, and Options C and D incorrect.




PreviousNext

Related