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

A lambda expression can only be used with which type of interface?

Q.242Easy

What is the return type of the lambda expression: (a, b) -> a > b?

Q.243Easy

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

Q.244Easy

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

Q.245Easy

Which of the following best describes a functional interface?

Q.246Easy

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

Q.247Easy

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

Q.248Easy

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

Q.249Easy

Which of the following lambda expressions is syntactically incorrect?

Q.250Easy

What is the purpose of a Predicate functional interface in Java?

Q.251Easy

In a lambda expression, what does the arrow (->) operator represent?

Q.252Easy

What is the correct syntax for a lambda expression with no parameters that returns a fixed value?

Q.253Easy

Given: Function<Integer, Integer> f = x -> x * 2; Integer result = f.apply(5); What is the value of result?

Q.254Easy

Which functional interface is used to create a lambda expression that takes two integers and returns a boolean value?

Q.255Easy

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

Q.256Easy

Which annotation is used to mark a class as a Spring Bean in the latest Spring Framework?

Q.257Easy

What is the primary purpose of Dependency Injection (DI) in Spring Framework?

Q.258Easy

Which of the following is NOT a valid Spring bean scope in Spring 5.x+?

Q.259Easy

What does @Autowired annotation do in Spring?

Q.260Easy

Which XML element is used to define a bean in Spring XML configuration?