1
Loading subject content…
Loading subject content…
Loading practice questions…
What is the output of the following program?
import java.util.*;
public class Main {
public static void main(String[] args) {
List<String> w = List.of("apple", "avocado", "banana");
System.out.println(w.stream().anyMatch(s -> s.startsWith("b")) + " " + w.stream().allMatch(s -> s.startsWith("a")));
}
}What is the output of the following program?
public class Main {
public static void main(String[] args) {
java.util.function.Function<Integer, Integer> add1 = x -> x + 1;
java.util.function.Function<Integer, Integer> dbl = x -> x * 2;
System.out.println(add1.andThen(dbl).apply(5));
}
}What is the output of the following program?
import java.util.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) {
Map<Integer, Long> byLen = Stream.of("to", "be", "or", "not").collect(java.util.stream.Collectors.groupingBy(String::length, TreeMap::new, java.util.stream.Collectors.counting()));
System.out.println(byLen);
}
}