Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
22.11. Stream API and Lambda Expressions
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
2 cards from this lesson. Good the night before a test.
Try these first
- 1.
What is the purpose of the Stream API in Java?
Hint
Think about how it allows operations to be performed on collections.
- 2.
What is a lambda expression?
Hint
Recall the syntax: (parameters) -> expression.
- 3.
What operation would you use to remove elements that do not meet a condition in a Stream?
- Map
- Filter
- Reduce
Hint
Consider which operation narrows down the elements.
- 4.
True or False: Lambda expressions can express behaviors that are passed into methods.
- True
- False
Hint
Think about the flexibility they provide in method parameters.
- 5.
Write a method that returns a List of squared values from an input List of integers using the Stream API.
Hint
Think about what map will do with the elements.
- 6.
Using the Stream API, how would you count the total number of words in a list of sentences?
Hint
Consider how to break down the sentences into their components.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting