iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

951 questions | 100% Free

Q.821Medium

Which of the following lambda expressions is INCORRECT?

Q.822Medium

Consider: Stream.of(1, 2, 3, 4, 5).filter(x -> x > 2).map(x -> x * x). What will the terminal operation need to be?

Q.823Medium

What is method reference (::) in Java and how does it relate to lambda expressions?

Q.824Medium

What is the difference between peek() and forEach() when used with lambda expressions in Streams?

Q.825Medium

In the lambda expression (a, b) -> a.compareTo(b), what is the implicit functional interface?

Q.826Medium

What will be the output of: IntStream.range(1, 4).map(x -> x * 2).sum();

Q.827Hard

Consider a lambda that needs to throw a checked exception. Which approach is correct?

Q.828Hard

What is the time complexity of reducing a stream with a lambda expression using reduce()?

Q.829Hard

Consider: List<String> list = Arrays.asList("a", "b", "c"); list.stream().collect(Collectors.toMap(s -> s, s -> s.length())). What type is returned?

Q.830Hard

What issue can arise when using lambda expressions with flatMap() in nested streams?

Q.831Hard

Consider: Function<Integer, Function<Integer, Integer>> curry = x -> y -> x + y; What does curry.apply(5).apply(3) return?

Q.832Easy

What is the primary advantage of using lambda expressions in Java 8+?

Q.833Easy

What will be the output of: List<String> list = Arrays.asList("a", "bb", "ccc"); list.forEach(s -> System.out.print(s.length() + " "));

Q.834Easy

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

Q.835Easy

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

Q.836Medium

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

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

Q.838Medium

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

Q.839Medium

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

Q.840Medium

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