Java SE 8 Programmer II — Question 189
Which statement is true about the single abstract method of the java.util.function.Predicate interface?
Answer options
- A. It accepts one argument and returns void.
- B. It accepts one argument and returns boolean.
- C. It accepts one argument and always produces a result of the same type as the argument.
- D. It accepts an argument and produces a result of any data type.
Correct answer: B
Explanation
The correct answer is B because the single abstract method in the Predicate interface is designed to accept one argument and return a boolean value indicating the evaluation result. Option A is incorrect as it states that the method returns void, which is not true. Options C and D misrepresent the return type of the method, which specifically returns a boolean and not a result of the same type as the argument or any data type.