Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - 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:

Brittni
1 months ago
Wow, these Java stream questions are trickier than a maze of tangled wires! I better brush up on my lambda expressions and default methods before the exam.
upvoted 0 times
...
Tran
1 months ago
D) A compilation error occurs at line n2. The second filter should use the variable cf2 instead of the anonymous class implementation directly.
upvoted 0 times
Sanjuana
12 days ago
C) A compilation error occurs at line n1.
upvoted 0 times
...
Sherly
17 days ago
B) 3
upvoted 0 times
...
Jani
19 days ago
A) 2
upvoted 0 times
...
...
Donette
1 months ago
C) A compilation error occurs at line n1. The CourseFilter interface extends Predicate, so the anonymous class implementation should use the default method test() instead of overriding it.
upvoted 0 times
Sherita
7 days ago
C) A compilation error occurs at line n1.
upvoted 0 times
...
Cherry
10 days ago
B) 3
upvoted 0 times
...
Nakita
12 days ago
A) 2
upvoted 0 times
...
...
Eun
2 months ago
I think the answer is A) 2. The first filter (cf1) will remove 'Java ME' since it has a length of 6, and the second filter (cf2) will keep 'Java' and 'Java EE', so the final count should be 2.
upvoted 0 times
Candra
14 days ago
Oh, I see. Thanks for the clarification!
upvoted 0 times
...
Bernardo
15 days ago
No, the correct answer is B) 3. The first filter (cf1) will remove 'Java ME' but the second filter (cf2) will keep 'Java' and 'Java EE', resulting in a count of 3.
upvoted 0 times
...
Mary
27 days ago
A) 2
upvoted 0 times
...
...
Jamey
2 months 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
Tatum
1 months ago
D) A compilation error occurs at line n2.
upvoted 0 times
...
Antonio
1 months ago
C) A compilation error occurs at line n1.
upvoted 0 times
...
Kristeen
1 months ago
B) 3
upvoted 0 times
...
Sharika
2 months ago
A) 2
upvoted 0 times
...
...
Avery
2 months 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
2 months ago
I disagree, I believe the answer is A) 2.
upvoted 0 times
...
Avery
2 months ago
I think the answer is B) 3.
upvoted 0 times
...
Brice
2 months ago
I'm not sure, but I think there might be a compilation error at line n2.
upvoted 0 times
...
Tiffiny
2 months ago
I believe the result is 3.
upvoted 0 times
...
Brice
2 months 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