Q. What is the purpose of the peek() method in a stream pipeline?
β
Correct Answer: (B)
To inspect the stream elements
Explanation: The peek() method allows you to perform a side-effect on each element of the stream without modifying the stream itself.