iGET

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

Q.61Medium

Which functional interface should be used for a lambda with no parameters and no return value?

Q.62Medium

What is the difference between Consumer and Function functional interfaces?

Q.63Medium

Which of the following uses method reference correctly?

Q.64Medium

Which of the following lambda expressions will compile successfully?

Q.65Easy

What is the output of: BiFunction<Integer, Integer, Integer> add = (a, b) -> a + b; System.out.println(add.apply(5, 3));

Q.66Medium

In the lambda expression (x) -> x < 10 && x > 0, what is the parameter type?

Q.67Medium

Which of the following statements about variable scope in lambda expressions is TRUE?

Q.68Easy

What is the result of this code? UnaryOperator<Integer> square = x -> x * x; System.out.println(square.apply(5));

Q.69Easy

Which of the following best describes a functional interface?

Q.70Easy

What will be the output of: Supplier<String> greeting = () -> "Hello"; System.out.println(greeting.get());

Q.71Medium

Consider: Comparator<String> comp = (s1, s2) -> s2.compareTo(s1); What does this lambda expression do?

Q.72Medium

Which lambda expression is equivalent to the method reference Integer::parseInt?

Q.73Hard

What is the correct way to chain lambda expressions using Function interface? Function<Integer, Integer> f1 = x -> x * 2; Function<Integer, Integer> f2 = x -> x + 5; How to apply f1 first, then f2?

Q.74Medium

Analyze: What is the output? BiConsumer<String, String> printer = (a, b) -> System.out.println(a + b); printer.accept("Java", "8");

Q.75Easy

Which of the following is a valid functional interface that can be used with lambda expressions?

Q.76Medium

What is the return type of a lambda expression (x, y) -> x + y where x and y are integers?

Q.77Easy

Which annotation is used to mark an interface as a functional interface in Java?

Q.78Medium

Consider a lambda expression: (String s) -> s.length(). What is the correct functional interface for this?

Q.79Medium

What will happen if you try to access a local variable from an enclosing scope that is not final or effectively final in a lambda expression?

Q.80Easy

Which of the following lambda expressions is syntactically incorrect?