Oracle
1Z0-829 · Question #26
1Z0-829 Question #26: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #26. The question stem and answer options stay visible for context.
Working with Streams and Lambda expressions
Question
Given:
public class Test {
public String attach1(List<String> data) {
return data.parallelStream().reduce("w", (n,m) -> n+m, String::concat);
}
public String attach2(List<String> data) {
return data.parallelStream().reduce((p,l) -> p+l).get();
}
public static void main(String[] args) {
Test t = new Test();
var list = List.of("Table", "Chair");
String x = t.attach1(list);
String y = t.attach2(list);
System.out.print(x + "+" + y);
}
}
What is the result?
Options
- ATablechair Tablechair
- BWTablechair Tablechair
- CA NullPointerException is thrown
- DWTablechair TableChair
- ECompilation fails
Unlock 1Z0-829 to see the answer
You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 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.
Topics
#Parallel Streams#Stream.reduce()#Type Inference#Lambda Expressions