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

What is the primary purpose of lambda expressions introduced in Java 8?

Q.802Easy

Which of the following is a valid lambda expression syntax in Java?

Q.803Easy

What is a functional interface in Java?

Q.804Easy

Which package contains the built-in functional interfaces in Java?

Q.805Easy

What will be the output of the following code? UnaryOperator<Integer> square = x -> x * x; System.out.println(square.apply(5));

Q.806Medium

Which of the following lambda expressions is invalid?

Q.807Medium

What is the type of the following lambda expression: x -> x.length()?

Q.808Medium

Which functional interface should be used for a lambda that filters elements?

Q.809Medium

What will this code print? List<Integer> list = Arrays.asList(1, 2, 3, 4, 5); list.forEach(x -> System.out.print(x + " "));

Q.810Medium

Can lambda expressions access local variables from their enclosing scope?

Q.811Medium

Which of the following correctly represents a BiFunction?

Q.812Medium

What is the difference between a lambda expression and an anonymous inner class?

Q.813Hard

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));

Q.814Medium

Which of the following statements about @FunctionalInterface is true?

Q.815Easy

What is the output of this code? Consumer<String> print = s -> System.out.println(s.toUpperCase()); print.accept("java");

Q.816Medium

Can a lambda expression have multiple statements in its body?

Q.817Medium

Which functional interface is best suited for this scenario: method that takes no parameters and returns a random number?

Q.818Hard

What will happen if you try to compile this code? BiFunction<String, String, String> concat = (a, b) -> a + b; concat.apply("Java", "8", "Features");

Q.819Medium

In Java streams, what does the filter() method use?

Q.820Hard

What is the type inference mechanism in lambda expressions?