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));
What is the output of this code? Consumer<String> print = s -> System.out.println(s.toUpperCase()); print.accept("java");
In Java 8, a lambda expression can access local variables from its enclosing scope. What is the constraint on these variables?
What is the return type of the map() method when used with lambda expressions in Java Streams?
Consider the code: List<String> names = Arrays.asList("Raj", "Priya", "Amit"); names.forEach(n -> System.out.println(n)); What does this code do?
Which functional interface is used for operations that take no arguments and return a value?
What is the primary advantage of using lambda expressions in Java 8+?
What will be the output of: List<String> list = Arrays.asList("a", "bb", "ccc"); list.forEach(s -> System.out.print(s.length() + " "));
Which functional interface is used for operations that take two arguments and return a single value?
What is a method reference (::) in Java?
What is the purpose of the @FunctionalInterface annotation in Java?
Which stream operation would you use to transform elements from one type to another?
Which of the following is a valid lambda expression in Java?
A lambda expression can only be used with which type of interface?
What is the return type of the lambda expression: (a, b) -> a > b?
What is the output of: BiFunction<Integer, Integer, Integer> add = (a, b) -> a + b; System.out.println(add.apply(5, 3));