Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 110

Given:

and

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

    Correct Answer: B

    The correct interface to use from the java.util.function package for refactoring the class Txt is Predicate. A Predicate takes one argument and returns a boolean value. This matches the behavior described in the checkLength method of the LengthValidator interface, which accepts a String and returns a boolean based on the condition applied to the length of the string.

Discussion
SigamaniOption: B

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

JME_CHGOption: B

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

MatthewTannousOption: B

B because predicates return a boolean value

shivkumarxOption: B

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");

asdfjhfgjuaDCVOption: B

B is the correct answer

steefaandOption: B

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