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

Which functional interface is used for operations that take two arguments and return a single value?

Q.842Easy

What is a method reference (::) in Java?

Q.843Medium

Consider: Stream.of(1, 2, 3, 4, 5).filter(x -> x > 2).map(x -> x * 2).forEach(System.out::println); What will be the output?

Q.844Medium

What is the difference between peek() and forEach() in streams?

Q.845Medium

What issue can arise when using lambda expressions with checked exceptions?

Q.846Medium

What will be the output of: IntStream.range(1, 4).map(x -> x * x).forEach(System.out::print);

Q.847Medium

In the lambda expression (a, b) -> a.compareTo(b), what can we infer about the parameters?

Q.848Hard

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

Q.849Hard

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

Q.850Medium

Which of the following correctly uses method reference with constructor?

Q.851Medium

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

Q.852Hard

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

Q.853Easy

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

Q.854Easy

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

Q.855Medium

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

Q.856Easy

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

Q.857Easy

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

Q.858Easy

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

Q.859Medium

Which of the following lambda expressions has incorrect syntax?

Q.860Medium

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