Java Programming - MCQ Practice Questions
Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.
958 questions | 100% Free
What is the primary purpose of lambda expressions introduced in Java 8?
Which of the following is a valid lambda expression syntax in Java?
What is a functional interface in Java?
Which package contains the built-in functional interfaces in Java?
What will be the output of the following code? UnaryOperator<Integer> square = x -> x * x; System.out.println(square.apply(5));
Which of the following lambda expressions is invalid?
What is the type of the following lambda expression: x -> x.length()?
Which functional interface should be used for a lambda that filters elements?
What will this code print? List<Integer> list = Arrays.asList(1, 2, 3, 4, 5); list.forEach(x -> System.out.print(x + " "));
Can lambda expressions access local variables from their enclosing scope?
Which of the following correctly represents a BiFunction?
What is the difference between a lambda expression and an anonymous inner class?
What will be the output of this nested lambda? Function<Integer, Function<Integer, Integer>> add = x -> y -> x + y; System.out.println(add.apply(3).apply(5));
Which of the following statements about @FunctionalInterface is true?
What is the output of this code? Consumer<String> print = s -> System.out.println(s.toUpperCase()); print.accept("java");
Can a lambda expression have multiple statements in its body?
Which functional interface is best suited for this scenario: method that takes no parameters and returns a random number?
What will happen if you try to compile this code? BiFunction<String, String, String> concat = (a, b) -> a + b; concat.apply("Java", "8", "Features");
In Java streams, what does the filter() method use?
What is the type inference mechanism in lambda expressions?