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.861Medium

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

Q.862Medium

What is the difference between Consumer and Function functional interfaces?

Q.863Medium

Which of the following uses method reference correctly?

Q.864Medium

Which of the following lambda expressions will compile successfully?

Q.865Easy

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

Q.866Medium

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

Q.867Medium

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

Q.868Easy

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

Q.869Easy

Which of the following best describes a functional interface?

Q.870Easy

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

Q.871Medium

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

Q.872Medium

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

Q.873Hard

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.874Medium

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

Q.875Easy

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

Q.876Medium

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

Q.877Easy

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

Q.878Medium

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

Q.879Medium

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.880Easy

Which of the following lambda expressions is syntactically incorrect?