Choose the correct option based on this program:
import java.util.function.Predicate; public class Main { public static void main(String args[]){ Predicate<String> predContains = "I am going to write OCP8 exam"::contains; checkString(predContains, "OCPJP"); }/* ww w. ja v a 2 s .c om*/ static void checkString(Predicate<String> predicate, String str) { System.out.println(predicate.test(str) ? "contains" : "doesn't contain"); } }
main()
methodcheckString()
methodd.
You can create method references for object as well, so the code within main()
compiles without errors.
the code within checkString()
method is also correct and hence it also compiles without errors.
the string OCPJP
is not present in the string "I am going to write OCP8 exam" and hence this program prints "doesn't contain" on the console.