Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 33

Given:

What is the output?

    Correct Answer: A

    The code creates and manipulates a stream of strings from a list of fruits. It uses intermediate operations (`peek` and `sorted`) and a terminal operation (`collect`). Intermediate operations are lazy and are only executed when the terminal operation is called. The first `peek` prints items in their original order: 'banana', 'orange', 'apple', 'lemon'. This is followed by a separator. After the list is sorted, the second `peek` prints the items in their sorted order: 'apple', 'banana', 'lemon', 'orange'. Then the final separator is printed, resulting in the printed output: banana orange apple lemon ----- apple banana lemon orange -----

Discussion
RP384Option: D

Dis correct, until terminal operator is called the source won't generate streams.

thanhbtOption: C

C is correct

d7bb0b2Option: D

D is correct because only ----- print first and when collect is called execeute peek 1 (list in order original , sort , and peek2 (list ordered by natural order)

StavokOption: D

D is correct Tested

Mukes877Option: D

D is correct because Intermediate operations in a stream are lazy, meaning they are not evaluated until a terminal operation is invoked. The purpose of a terminal operation is to produce a result or perform a side effect.