Question 1
Which of the following statements is true about the difference between Streams and Collections in Java?
Streams store data, while Collections only provide access to data.
Collections are immutable, whereas Streams are mutable.
Streams allow for sequential and parallel execution, whereas Collections only work sequentially
Collections provide better performance than Streams.
Question 2
Which of these operations can be performed on a Collection but not on a Stream?
add()
map()
filter()
reduce()
Question 3
What is the purpose of the Collectors class in Java?
It provides various methods to collect elements from a stream into collections.
It performs the filtering operation on the elements in a stream.
It is used to combine the stream elements into a single value.
It allows parallel processing of stream elements.
Question 4
Which of the following is an example of a reduction operation on a stream?
map()
filter()
reduce()
collect()
Question 5
What type of operation is stream.forEach()?
Intermediate
Terminal
Reduction
Both intermediate and terminal
Question 6
How do streams handle null values?
Streams can contain null values, but operations like map() and filter() will fail if the stream contains null.
Streams can automatically filter out null values.
Streams do not support null values.
Streams handle null values by default.
Question 7
What is the return type of the Stream.collect() method?
List
Map
Set
It can return different types, such as List, Set, or Map
Question 8
Which of the following operations is NOT supported by Streams?
peek()
reduce()
add()
map()
Question 9
Which method can be used to transform a Stream into a List or Set?
collect()
map()
toArray()
filter()
Question 10
Which of the following operations can be performed using the Collectors class?
joining()
groupingBy()
partitioningBy()
All of the above
There are 10 questions to complete.