Streams Quiz 8
The quiz below tests your knowledge of the material learnt in Streams - Lesson 8 - Reduction Operations.
Question 1 : Which of the following is a specialised reduction operation of the Stream
interface?
- The <code>max()</code> method is a specialised reduction operation of the <code>Stream</code> interface.
Question 2 : All reduction operations are terminal?
- All reduction operations ARE terminal.
Question 3 : What is returned from the single parameter reduce()
method?
- An <code>Optional</code> is returned from the single parameter <code>reduce</code> method to remove <code>NullPointerException</code> scenarios.
Question 4 : All the specialised reduction operations return an Optional
?
- <code>min()</code> and <code>max()</code> return an <code>Optional</code> but <code>count()</code> returns a long.
Question 5 : reduce()
is one of the general reduction operations, what is the other?
- <code>collect</code> is a general reduction operation, the others answers are specialised reduction operations.
Question 6 : The reduce()
general reduction operation is the most efficient way of getting aggregates from streams?
- The <code>reduce()</code> general reduction operation is NOT the most efficient way of getting aggregates from streams as elements require boxing.
Question 7 : It is not possible to return null
from a specialised reduction operation?
- It is NOT possible to return <code>null</code> from a specialised reduction operation, <code>count()</code> will return <code>0</code> and <code>min()</code> and <code>max()</code> will return <code>Optional.empty</code>.
Quiz Progress Bar Please select an answer
What's Next?
In the next quiz we test your knowledge of stream collectors.