Collecting & Aggregating Streams QuizJ8 Home « Collecting & Aggregating Streams Quiz

Streams Quiz 10

The quiz below tests your knowledge of the material learnt in Streams - Lesson 10 - Collecting & Aggregating Streams.

Question 1 : Which Collectors method concatenates input elements into a String?
- The <code>joining()</code> method of the <code>Collectors</code> class concatenates input elements into a <code>String</code>.
Question 2 : The toMap() method can deal with duplicate keys?
- There is an override of the <code>toMap()</code> method which takes a third parameter to deal with duplicate keys.
Question 3 : Which of these methods requires a comparator?
- Both the <code>max()</code> and <code>maxBy()</code> methods require a comparator.
Question 4 : Streams can handle collections but not their implementations?
- Streams can handle collection implementations using the <code>toCollection()</code> static method of the <code>Collectors</code> class to pass a stream to an implementation such as <code>LinkedHashSet</code>.
Question 5 : Which interface does the Collectors class offer implementations of?
- The <code>Collectors</code> class implements the <code>Collector</code> interface.
Question 6 : Methods of the Collectors class are imported statically?
- Methods of the <code>Collectors</code> class ARE imported statically, as all methods in this class are static.
Question 7 : In which order are elements returned from the no parameter sorted() method of the Stream interface?
- The elements are returned in NATURAL order from the no parameter <code>sorted()</code> method of the <code>Stream</code> interface.
Question 8 : The sorted() method of the Stream interface is a terminal operation?
- The <code>sorted()</code> method of the <code>Stream</code> is NOT a terminal operation.
Quiz Progress Bar Please select an answer

What's Next?

In the next quiz we test your knowledge of grouping and partitioning our streams.