Oracle
1Z0-819 · Question #50
Given var numbers = List.of(1,2,3,4,5,6,7,8,9,10); for(int a: numbers){ StringBuilder sb = new StringBuilder(); sb.append(a); sb.append(""); system.out.println(sb.toString()); } Which statement on…
The correct answer is A. Function<Integer, Integer> f = n -> n*2. See the full explanation below for the reasoning.
Question
Given
var numbers = List.of(1,2,3,4,5,6,7,8,9,10);
for(int a: numbers){
StringBuilder sb = new StringBuilder();
sb.append(a);
sb.append("");
system.out.println(sb.toString());
}
Which statement on line 1 enables this code to compile?
Options
- AFunction<Integer, Integer> f = n -> n*2;
- BFunction<Integer> f = n -> n*2;
- CFunction<int> f = n -> n*2;
- DFunction<int,int> f = n -> n*2;
How the community answered
(27 responses)- A70% (19)
- B4% (1)
- C19% (5)
- D7% (2)
Community Discussion
No community discussion yet for this question.