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 13 Question 87 Discussion

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

Given the code fragment:

List str = Arrays.asList (''my'', ''pen'', ''is'', ''your', ''pen'');

Predicate test = s -> {

int i = 0;

boolean result = s.contains (''pen'');

System.out.print(i++) + '':'');

return result;

};

str.stream()

.filter(test)

.findFirst()

.ifPresent(System.out ::print);

What is the result?

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Sheridan
3 days ago
I'm not sure, but I think the answer might be E) A compilation error occurs because of a syntax error in the code
upvoted 0 times
...
Carey
7 days ago
I agree with Reyes, the code prints 0 : 1 : pen because of the way the Predicate is implemented
upvoted 0 times
...
Reyes
8 days ago
I think the answer is B) 0 : 1 : pen because the code fragment increments i each time it prints
upvoted 0 times
...
Sheridan
11 days ago
A) 0 : 0 : pen - This seems like the correct answer. The predicate checks if the string contains 'pen' and prints the value of the counter, which starts at 0 and increments for each match.
upvoted 0 times
Louvenia
3 days ago
A) 0 : 0 : pen
upvoted 0 times
...
...

Save Cancel