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

In Java streams, what does the filter() method use?

Q.402Medium

What will be the result of executing: List<Integer> nums = Arrays.asList(1, 2, 3, 4); nums.stream().map(x -> x * 2).collect(Collectors.toList());

Q.403Medium

Consider: Function<Integer, Integer> f = x -> x * x; What will f.apply(5) return?

Q.404Medium

What is the purpose of the Optional class when used with lambda expressions in Stream operations?

Q.405Medium

Which of the following lambda expressions is INCORRECT?

Q.406Medium

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

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

Q.408Medium

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

Q.409Medium

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

Q.410Medium

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

Q.411Medium

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

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

Q.413Medium

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

Q.414Medium

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

Q.415Medium

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

Q.416Medium

Which of the following correctly uses method reference with constructor?

Q.417Medium

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

Q.418Medium

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

Q.419Medium

Which of the following lambda expressions has incorrect syntax?

Q.420Medium

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