🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java 8 Lambdas and Streams: all 10 questions

Quiz: Java 8 Lambdas and Streams · Question 1 of 10

What does this print? (code)

What does this print?

import java.util.*;
public class Main {
    public static void main(String[] args) {
        List<Integer> l = List.of(1, 2, 3, 4, 5);
        System.out.println(l.stream().filter(x -> x % 2 == 1).map(x -> x * 10).toList());
    }
}
  1. A.[10, 20, 30, 40, 50]
  2. B.[10, 30, 50]
  3. C.[20, 40]
  4. D.[1, 3, 5]
Answer & explanation

Correct answer: [10, 30, 50]

Keep odd numbers (1, 3, 5), then multiply each by 10.

Can you get the rest right without peeking?

Take the timed Quiz: Java 8 Lambdas and Streams quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →