Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

1. What is the main function of the Stream interface in Java?

View

2. Which of the following methods is used to create a stream from a collection in Java?

View

3. Which method of the Stream interface is used to filter elements based on a condition?

View

4. Which method does ListIterator interface provide that Iterator does not?

View

5. Which of the following methods is not part of the Iterator interface?

View

6. Which statement is true regarding the use of Iterator?

View

7. Which of the following is not a valid type of stream in Java?

View

8. What is the output of the following code?

View

9. Which of the following is true about the Stream API?

View

10. Which of the following methods can be used to create a stream from an array?

View

1. What is the main function of the Stream interface in Java?

To allow functional programming features on collections
To allow multiple collections in one stream
To store data in a memory-efficient way
To support only one operation on data

2. Which of the following methods is used to create a stream from a collection in Java?

stream()
createStream()
toStream()
asStream()

3. Which method of the Stream interface is used to filter elements based on a condition?

map()
filter()
reduce()
collect()

4. Which method does ListIterator interface provide that Iterator does not?

previous()
hasNext()
remove()
next()

5. Which of the following methods is not part of the Iterator interface?

next()
hasNext()
remove()
add()

6. Which statement is true regarding the use of Iterator?

<p><br></p><p><br></p>

An Iterator can modify the collection while iterating.
The Iterator is thread-safe by default.
Iterator can only be used with a List.
Iterator is only used for retrieving elements, not for removing them.

7. Which of the following is not a valid type of stream in Java?

IntStream
DoubleStream c) LongStream
LongStream
StringStream

8. What is the output of the following code?

<p>Stream.of(1, 2, 3, 4, 5)<br>&nbsp; &nbsp; &nbsp; .filter(x -&gt; x % 2 == 0)<br>&nbsp; &nbsp; &nbsp; .count();<br><br></p>

2
3
1
5

9. Which of the following is true about the Stream API?

Streams are always mutable
A stream can be used only once
Streams are thread-safe by default
Streams are collections of data

10. Which of the following methods can be used to create a stream from an array?

Arrays.stream()
Stream.of()
Stream.fromArray()
Both a and b