Which of the following stream operations is a terminal operation?
- collect()
- filter()
- forEach()
- mapToDouble()
In Java Streams API, a terminal operation is an operation that produces a result or a side-effect. The collect() method is a terminal operation that collects the elements of a stream into a new collection or performs some other final action. Options 1 to 3 are intermediate operations, which transform or filter the elements but do not terminate the stream.
Loading...
Related Quiz
- Which of the following expressions will result in a value of true?
- In a system where multiple classes inherit from a single superclass and require unique methods alongside overridden methods from the superclass, how would you manage code organization and method overriding to ensure system consistency and minimize code duplication?
- If a class has multiple constructors, it can be said to have constructor ________.
- Which method is used to display a stage in JavaFX?
- The keyword ________ is used within a constructor to call another constructor in the same class.