Choose the correct option based on this code segment:
String []exams = { "OCAJP 8", "OCPJP 8", "Upgrade to OCPJP 8" }; Predicate isOCPExam = exam -> exam.contains("OCP"); // LINE-1 List<String> ocpExams = Arrays.stream(exams) .filter(exam -> exam.contains("OCP")) .collect(Collectors.toList()); // LINE-2 boolean result = ocpExams.stream().anyMatch(exam -> exam.contains("OCA")); // LINE-3 System.out.println(result);
a)
the functional interface Predicate<T> takes type T as the generic parameter that is not specified in LINE-1.
this results in a compiler error because the lambda expression uses the method contains()
in the call exam.contains("OCP").
If Predicate<String> were specified, this code segment would compile without errors, and when executed will print "false".