Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 5 Question 67 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 67
Topic #: 5
[All 1Z0-809 Questions]

Given the code fragments:

interface CourseFilter extends Predicate {

public default boolean test (String str) {

return str.equals (''Java'');

}

}

and

List strs = Arrays.asList(''Java'', ''Java EE'', ''Java ME'');

Predicate 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?

Show Suggested Answer Hide Answer
Suggested Answer: B, C

Contribute your Thoughts:

Jamey
11 days ago
The correct answer is B) 3. The first filter (cf1) checks for strings with length greater than 3, and the second filter (cf2) checks for strings containing 'Java'. The resulting stream will contain 'Java', 'Java EE', and 'Java ME', so the count is 3.
upvoted 0 times
...
Avery
14 days ago
But doesn't cf2 need to be cast to Predicate at line n2? I think the answer might be D) A compilation error occurs at line n2.
upvoted 0 times
...
Lilli
16 days ago
I disagree, I believe the answer is A) 2.
upvoted 0 times
...
Avery
17 days ago
I think the answer is B) 3.
upvoted 0 times
...
Brice
19 days ago
I'm not sure, but I think there might be a compilation error at line n2.
upvoted 0 times
...
Tiffiny
22 days ago
I believe the result is 3.
upvoted 0 times
...
Brice
23 days ago
I think the result is 2.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77