Streams Quiz 1
The quiz below tests your knowledge of the material learnt in Streams - Lesson 1 - Introducing Streams.
Question 1 : In which version of Java was the Streams API added to the language
- The Streams API was added to Java in version 8.
Question 2 : What is returned after a stream has finished processing?
- After a stream has finished processing it can return <code>void</code>, an object type, a primitive type and also a collection or array.
Question 3 : Streams preserve ordering?
- There is no mutation of elements within a stream, so if the source is from something ordered like a list the stream will preserve the ordering of the list.
Question 4 : How many terminal operations should a stream have?
- Although a stream can have <code>0</code> terminal operations this is pointless as the stream will never execute and so a stream should have only ONE terminal operation.
Question 5 : Streams adopt an iterative approach to programming?
- Streams adopt a DECLARATIVE approach to programming.
Question 6 : What is an advantage of using streams?
- Streams are lazily loaded which can lead to benefits in performance.
Question 7 : Streams are consumed after use?
- Streams ARE consumed after use, meaning they can only be traversed once.
Question 8 : How many intermediate operations can a stream have?
- A stream can have ZERO, ONE or MULTIPLE intermediate operation.
Question 9 : Streams are persisted?
- Streams are NOT persisted although the elements can be stored in an underlying collection or generated when needed
Quiz Progress Bar Please select an answer
In the next quiz we test your knowledge of stream pipelining.