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

What is the difference between a lambda expression and an anonymous inner class?

Q.402Medium

Which of the following statements about @FunctionalInterface is true?

Q.403Medium

Can a lambda expression have multiple statements in its body?

Q.404Medium

Which functional interface is best suited for this scenario: method that takes no parameters and returns a random number?

Q.405Medium

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

Q.406Medium

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

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

Q.408Medium

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

Q.409Medium

Which of the following lambda expressions is INCORRECT?

Q.410Medium

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

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

Q.412Medium

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

Q.413Medium

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

Q.414Medium

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

Q.415Medium

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

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

Q.417Medium

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

Q.418Medium

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

Q.419Medium

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

Q.420Medium

Which of the following correctly uses method reference with constructor?