Java 8 Objective Questions and Answers - Set 2

This Java 8 quiz is designed to test your skills with modern Java features. It focuses on practical understanding, output-based questions, and advanced concepts commonly asked in interviews and real-world development. This is part 2 of the series.

Practice Java 8 MCQs with Detailed Explanations

Answer at least 12 questions to submit and verify answers.

16 What is the main benefit of parallel streams? Medium

17 Which method converts a Stream back to a List? Medium

18 What does the peek() method do in a stream? Medium

19 Which interface is the base for all lambda expressions? Medium

20 What will be the output? Optional<String> opt = Optional.ofNullable(null); System.out.println(opt.orElse("Java")); Medium

21 Which Java 8 feature enables behavior parameterization? Medium

22 Which Collector is used to group elements in a stream? Medium

23 What does CompletableFuture improve over Future? High

24 Which method was added to String in Java 11? Medium

25 Which statement about streams is correct? Medium

26 Which functional interface returns a boolean result? Medium

27 What is the default behavior of Comparator.comparing()? Medium

28 Which Java feature allows interfaces to have method implementations? Medium

29 What will happen if two interfaces provide the same default method? High

30 Which method creates an infinite stream? Medium