Topic: 1z0-809 topic 1 question 110

Given:
and

Which interface from the java.util.function package should you use to refactor the class Txt?

A.
Consumer
B.
Predicate
C.
Supplier
D.
Function

Re: 1z0-809 topic 1 question 110

B is correct. predicate accepts one parameter and returns boolean value

Re: 1z0-809 topic 1 question 110

B, return is boolean, and takes 1 argument...

Re: 1z0-809 topic 1 question 110

It is predicate, we can replace the annoymous local class with a Predicate implementation:
Predicate<String> checkLength = str -> str.length()>5 && str.length()<10;
boolean res = checkLength("Hello");

Re: 1z0-809 topic 1 question 110

B is the correct answer

Re: 1z0-809 topic 1 question 110

B is correct as Predicate accepts one argument and returns boolean.

Re: 1z0-809 topic 1 question 110

B because predicates return a boolean value