What is Predicate in JAVA 8 ? Mphasis Interview Question-2022

Predicate in JAVA 8: Predicate is a built in functional interface present in java.util.function package. It is specifically used for code management and unit testing. It contains built in functions which is as follows: test(T t) :- It evaluates the predicate on the value passed to this function as the argument and then returns a boolean value. Example: import java.util.function.Predicate; class TestExample { public static void main(String[] args) { Predicate<Integer> greater_than = x -> (x > 100); // calling test method of the predicate System.out.println(greater_than.test(200)); } }