Oracle
1Z0-809 · Question #275
1Z0-809 Question #275: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #275. The question stem and answer options stay visible for context.
Question
QUESTION 299
Given the code fragment:
List<String> str = Arrays.asList("pen", "is", "not", "a", "pencil");
if (name.length () < 60) {
throw new UserException ();
} else if (age > 60) {
throw new AgeOutOfLimitException ();
} else {
System.out.println("User is registered.");
}
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: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.