Skip to content
CodeKruPro

Read a stream pipeline

QuizMediumJava onlyAsked in: Accenture, Capgemini, TCS

What does this print?

List<String> names = List.of("Asha", "Ravi", "Anil", "Bea", "arun");
System.out.println(names.stream()
    .filter(n -> n.startsWith("A"))
    .map(String::toUpperCase)
    .sorted()
    .collect(Collectors.toList()));
  • [ANIL, ASHA]
  • [ANIL, ARUN, ASHA]
  • [ASHA, ANIL]
  • [Anil, Asha]

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in