exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 60 discussion

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

Given the code fragment:
List<String> nL = Arrays.asList("Jim", "John", "Jeff");
Function<String, String> funVal = s -> "Hello : ".contact(s); nL.Stream()
.map(funVal)
.peek(System.out::print);
What is the result?

  • A. Hello : Jim Hello : John Hello : Jeff
  • B. Jim John Jeff
  • C. The program prints nothing.
  • D. A compilation error occurs.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
speed045
Highly Voted 3 years, 8 months ago
Correct answer is C, since peek is an intermediate lazy operation which will not be evaluated unless the pipeline is ended with a terminating operation.
upvoted 6 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 3 weeks ago
C is the correct answer:tested
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: C
C is correct, since there is no terminal operation and Stream is never run.
upvoted 1 times
...
nikhil_3011
2 years, 6 months ago
Answer is C. if we use any terminal operation after peek like .count()( even though its bad o/p formatting) then the answer would be A.
upvoted 2 times
...
Svetleto13
3 years, 2 months ago
Correct answer is C.If we replace peek with forEach answer is A
upvoted 4 times
...
ayzo
3 years, 6 months ago
Answer is A tested: class Testing { public static void main (String[] args) throws IOException{ List<String> nL = Arrays.asList("Jim ", "John ", "Jeff"); Function<String, String> funVal = s -> "Hello : ".concat(s); nL.stream() .map(funVal) .forEach(s-> System.out.print (s)); } } output: Hello : Jim Hello : John Hello : Jeff
upvoted 1 times
pridemore
3 years, 5 months ago
there is no terminal operation .forEach() that was called
upvoted 1 times
...
...
johnchen88
4 years, 6 months ago
The Correct Answer should be D; If ignore the typo of "Hello : ".contact(s), C is the correct answer
upvoted 1 times
...
Innovation
4 years, 6 months ago
it prints nothing. if we change peek to forEach, the output would be Hello : JimHello : JohnHello : Jeff
upvoted 3 times
...
Destroyer
4 years, 7 months ago
D is correct. We have no String.contact method
upvoted 1 times
M_Jawad
4 years, 6 months ago
it is String.concat
upvoted 1 times
...
...
thetech
4 years, 8 months ago
Answer is C. Tested.
upvoted 3 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