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 result of this code? UnaryOperator<Integer> square = x -> x * x; System.out.println(square.apply(5));
Which of the following best describes a functional interface?
What will be the output of: Supplier<String> greeting = () -> "Hello"; System.out.println(greeting.get());
Which of the following is a valid functional interface that can be used with lambda expressions?
Which annotation is used to mark an interface as a functional interface in Java?
Which of the following lambda expressions is syntactically incorrect?
What is the purpose of a Predicate functional interface in Java?
In a lambda expression, what does the arrow (->) operator represent?
What is the correct syntax for a lambda expression with no parameters that returns a fixed value?
Given: Function<Integer, Integer> f = x -> x * 2; Integer result = f.apply(5); What is the value of result?
Which functional interface is used to create a lambda expression that takes two integers and returns a boolean value?
What will be the output of the following code? List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5); numbers.stream().filter(n -> n % 2 == 0).forEach(System.out::println);