iGET

Java Programming - MCQ Practice Questions

Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.

951 questions | 100% Free

Q.21Easy

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

Q.22Easy

Which of the following best describes a functional interface?

Q.23Easy

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

Q.24Easy

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

Q.25Easy

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

Q.26Easy

Which of the following lambda expressions is syntactically incorrect?

Q.27Easy

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

Q.28Easy

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

Q.29Easy

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

Q.30Easy

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

Q.31Easy

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

Q.32Easy

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