exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 173 discussion

Actual exam question from Oracle's 1z0-809
Question #: 173
Topic #: 1
[All 1z0-809 Questions]

Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.contains ("Java");
}
}
and
List<String> strs = Arrays.asList("Java", "Java EE", "Embedded Java");
Predicate<String> cf1 = s - > s.length() > 3;
Predicate cf2 = new CourseFilter() { //line n1
public boolean test (String s) {
return s.startsWith ("Java");
}
};
long c = strs.stream()
.filter(cf1)
.filter(cf2 //line n2
.count();
System.out.println(c);
What is the result?

  • A. 2
  • B. 3
  • C. A compilation error occurs at line n1.
  • D. A compilation error occurs at line n2.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Huim
Highly Voted 3 years, 2 months ago
When no bracket is missing, then A.
upvoted 6 times
vancuver
2 years, 11 months ago
Tested, true
upvoted 1 times
...
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: A
A assuming missing bracket is typo.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: A
A is correct, the bracket just a typo
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is A.
upvoted 2 times
...
Svetleto13
3 years, 2 months ago
Ok.I tested the code with JDK8 and JDK14.Both gave answer A.So I dont know how others got answer B?
upvoted 1 times
...
maslac
3 years, 3 months ago
Answer is B. Tested
upvoted 1 times
...
MilkBiscuit
3 years, 7 months ago
Seriously? because line n2 misses a closing bracket?
upvoted 1 times
mevlt
2 years, 5 months ago
I believe that is just a typo.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago