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

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

Q.42Easy

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

Q.43Medium

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.44Medium

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

Q.45Medium

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

Q.46Medium

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

Q.47Medium

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

Q.48Hard

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

Q.49Hard

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

Q.50Medium

Which of the following correctly uses method reference with constructor?

Q.51Medium

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

Q.52Hard

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

Q.53Easy

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

Q.54Easy

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

Q.55Medium

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

Q.56Easy

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

Q.57Easy

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

Q.58Easy

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

Q.59Medium

Which of the following lambda expressions has incorrect syntax?

Q.60Medium

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