0 votes
in JAVA by
Which of the following is true about the Stream.sorted() method in Java 8?

a) It sorts the elements of the stream in natural order.

b) It sorts the elements of the stream using the specified Comparator.

c) It returns a new stream that is the result of applying a reduction operation to the elements of the stream.

d) It performs a filter operation on the elements of the stream.

1 Answer

0 votes
by

Answer: b) It sorts the elements of the stream using the specified Comparator.

Explanation: The Stream.sorted() method sorts the elements of the stream using the specified Comparator, or in natural order if no Comparator is provided.

...