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.841Hard

What is the time complexity of reducing a stream with a stateful lambda operation?

Q.842Hard

Consider: Function<Integer, Function<Integer, Integer>> curried = a -> b -> a + b; What is this pattern called?

Q.843Medium

Which of the following correctly uses method reference with constructor?

Q.844Medium

What happens when a lambda expression references a local variable from its enclosing scope?

Q.845Hard

Consider: Stream.of(1, 2, 3).map(x -> { System.out.println(x); return x * 2; }).collect(Collectors.toList()); What will print?

Q.846Easy

What is the purpose of the @FunctionalInterface annotation in Java?

Q.847Easy

Which stream operation would you use to transform elements from one type to another?

Q.848Medium

What will be the output of: List<Integer> list = Arrays.asList(1, 2, 3); list.replaceAll(x -> x * 2); System.out.println(list);

Q.849Easy

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

Q.850Easy

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

Q.851Easy

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

Q.852Medium

Which of the following lambda expressions has incorrect syntax?

Q.853Medium

What will be the type of the lambda expression (x) -> x.toString()?

Q.854Medium

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

Q.855Medium

What is the difference between Consumer and Function functional interfaces?

Q.856Medium

Which of the following uses method reference correctly?

Q.857Medium

Which of the following lambda expressions will compile successfully?

Q.858Easy

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

Q.859Medium

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

Q.860Medium

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