What is the result?

Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.equals (“Java”);}
}
and
List<String> strs = Arrays.asList(“Java”, “Java EE”, “Java ME”);
Predicate<String> cf1 = s – > s.length() > 3;
Predicate cf2 = new CourseFilter() { //line n1
public boolean test (String s) {
return s.contains (“Java”);
}
};
long c = strs.stream()
.filter(cf1)
.filter(cf2 //line n2
.count();
System.out.println(c);
What is the result?

Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.equals (“Java”);}
}
and
List<String> strs = Arrays.asList(“Java”, “Java EE”, “Java ME”);
Predicate<String> cf1 = s – > s.length() > 3;
Predicate cf2 = new CourseFilter() { //line n1
public boolean test (String s) {
return s.contains (“Java”);
}
};
long c = strs.stream()
.filter(cf1)
.filter(cf2 //line n2
.count();
System.out.println(c);
What is the result?

A.
2

B.
3

C.
A compilation error occurs at line n1.

D.
A compilation error occurs at line n2.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Berti John

Berti John

B is correct