Question: Which of the following operations is a terminal operation in Java 8 Stream API?
Options:
A. map()
B. filter()
C. collect()
D. flatMap()
Answer:
C. collect()
Explanation:
The collect() method is a terminal operation in the Stream API, used to transform the elements of a stream into a collection, list, or another data structure. Terminal operations produce a result or a side-effect and close the stream.
Master the Java 8 Stream API concepts to stand out in your interviews!