Oracle
1Z0-809 · Question #20
1Z0-809 Question #20: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #20. The question stem and answer options stay visible for context.
Question
Given the code fragment:
List<String> str = Arrays.asList("my", "pen", "is", "your", "pen");
Predicate<String> 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?
Options
- A0:0:pen
- B0:1:pen
- C0:0:0:0:0:pen
- D0:1:2:3:4:
- EA compilation error occurs.
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.