Java Streams MCQs with answers Page - 1

You will find multiple-choice questions (MCQs) related to #Java Streams here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 802.91K Points
Coach

Q. Which method is used to transform elements in a Stream?

  • (A) filter()
  • (B) map()
  • (C) forEach()
  • (D) collect()

A

Admin • 802.91K Points
Coach

Q. What does the filter() method do in a Stream?

  • (A) Filters based on a condition
  • (B) Sorts the stream
  • (C) Transforms data
  • (D) Reduces the stream

A

Admin • 802.91K Points
Coach

Q. Which method converts a Stream into a List?

  • (A) toList()
  • (B) collect(Collectors.toList())
  • (C) toArray()
  • (D) convertToList()

A

Admin • 802.91K Points
Coach

Q. Which Stream method is used to perform an action for each element?

  • (A) collect()
  • (B) map()
  • (C) forEach()
  • (D) reduce()

A

Admin • 802.91K Points
Coach

Q. Which operation is terminal in Stream API?

  • (A) map()
  • (B) filter()
  • (C) limit()
  • (D) collect()

A

Admin • 802.91K Points
Coach

Q. Which method returns the count of elements in the Stream?

  • (A) size()
  • (B) count()
  • (C) length()
  • (D) total()

A

Admin • 802.91K Points
Coach

Q. Which method is used to sort elements of a Stream?

  • (A) sort()
  • (B) arrange()
  • (C) sorted()
  • (D) orderBy()

A

Admin • 802.91K Points
Coach

Q. Which method limits the number of elements in the stream?

  • (A) cap()
  • (B) restrict()
  • (C) limit()
  • (D) slice()

A

Admin • 802.91K Points
Coach

Q. What is a terminal operation in a stream?

  • (A) An operation that ends stream processing
  • (B) An operation that filters the stream
  • (C) An operation that sorts the stream
  • (D) An operation that maps the stream

A

Admin • 802.91K Points
Coach

Q. What is the use of `reduce()` in streams?

  • (A) To reduce stream size
  • (B) To perform aggregation
  • (C) To filter elements
  • (D) To convert to list
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More