Other Stream Creation QuizS2C Home « Other Stream Creation Quiz

The questions in this quiz on Java are on the topics covered in the Streams section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Generics Lessons Description Quiz Info.
Lesson 1 - Introducing StreamsIn our first lesson on on Streams we test your knowledge of the topics covered in the Introducing Streams lesson.Quiz1
9 questions
Lesson 2 - Stream PipelinesIn this lesson on streams we look at stream pipelines and how they work.Quiz2
9 questions
Lesson 3 - Stream Operations OverviewIn this lesson on streams we present an overview of the intermediate and terminal operations available.Quiz3
9 questions
Lesson 4 - Array Type StreamsIn this streams lesson we look at the various ways of creating streams from arrays.Quiz4
8 questions
Lesson 5 - Numeric StreamsIn this lesson on streams we look at numeric streams and the operations associated with them.Quiz5
7 questions
Lesson 6 - Other Stream CreationIn this lesson we take a final look at stream creation by creating streams from files, functions and iterations and also find out about creating infinite streams.This quiz.
9 questions
Lesson 7 - Finding & MatchingIn this streams lesson we look at the various ways of finding and matching values within our streams.Quiz7
9 questions
Lesson 8 - Reduction OperationsIn this streams lesson we look at reduction operations and how to use them.Quiz8
7 questions
Lesson 9 - Stream CollectorsIn this lesson we take a high level look at stream collectors by investigating the Collector<T,A,R> interface and the Collectors class implementation of it.Quiz9
8 questions
Lesson 10 - Collecting & Aggregating StreamsIn this lesson we look at how to create collections and aggregations from our streams.Quiz9
8 questions
Lesson 11 - Grouping & Partitioning StreamsThis lesson on streams is all about grouping & partitioning our streams.Quiz11
9 questions
Lesson 12 - Parallel StreamsThis lesson is all about parallel streams.Quiz12
8 questions

Streams Quiz 6

The quiz below tests your knowledge of the material learnt in Streams - Lesson 6 - Other Stream Creation.

Question 1 : The generate() method produces values from a constant iteration over a function?
- The <code>generate()</code> method produces new values, its the <code>iterate()</code> method that produces values from a constant iteration over a function.
Question 2 : Which Files class static method returns a lazily populated Stream, the elements of which are the entries in the directory?
- The <code>list()</code> static method of the <code>Files</code> class returns a lazily populated <code>Stream</code>, the elements of which are the entries in the directory.
Question 3 : We can create infinite streams?
- We CAN create infinite streams using the <code>iterate()</code> and <code>generate()</code> methods.
Question 4 : If you were extracting lines from a file and you wanted just one stream rather than a stream for each line which method would you use to achieve this?
- If you were extracting lines from a file and you wanted just one stream rather than a stream for each line you would use the <code>flatMap()</code> method.
Question 5 : The count() method can be used to restrict infinite streams?
- The <code>count()</code> method is a terminal operator that just sums up the values of a stream. To restrict infinite streams we would use the <code>limit()</code> intermediate operator to limit the size of the stream.
Question 6 : Which of the following methods will process a function infinitely?
- The <code>iterate()</code> method will process a function infinitely.
Question 7 : The java.nio.file Api was specifically updated in Java8 to take advantage of streams
- The <code>java.nio.file</code> Api WAS specifically updated in Java8 to take advantage of streams.
Question 8 : Which of the following methods can produce an infinite stream?
- The <code>generate()</code> method CAN produce an infinite stream.
Question 9 : The iterate() method produces bounded streams?
- The <code>iterate()</code> method DOES NOT produce <i>bounded</i> streams because results are produced <i>on the fly</i>, so can be infinite or <i>unbounded</i>.
Quiz Progress Bar Please select an answer

What's Next?

In the next quiz we test your knowledge of stream finding and matching operations.