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.181Hard

Which Java feature was introduced specifically to support generics compilation?

Q.182Hard

A method processes collections where items need to be added back to the same collection type. Which wildcard approach ensures type safety for write operations?

Q.183Hard

What will be the output of this nested lambda? Function<Integer, Function<Integer, Integer>> add = x -> y -> x + y; System.out.println(add.apply(3).apply(5));

Q.184Hard

What will happen if you try to compile this code? BiFunction<String, String, String> concat = (a, b) -> a + b; concat.apply("Java", "8", "Features");

Q.185Hard

What is the type inference mechanism in lambda expressions?

Q.186Hard

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

Q.187Hard

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

Q.188Hard

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

Q.189Hard

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

Q.190Hard

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

Q.191Hard

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

Q.192Hard

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

Q.193Hard

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

Q.194Hard

What is the correct way to chain lambda expressions using Function interface? Function<Integer, Integer> f1 = x -> x * 2; Function<Integer, Integer> f2 = x -> x + 5; How to apply f1 first, then f2?

Q.195Hard

Consider a scenario where you need to sort a list of strings by length. Which lambda expression is most appropriate for Comparator?

Q.196Hard

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

Q.197Hard

In the context of exception handling with lambda expressions, what happens if a lambda body throws a checked exception?

Q.198Hard

Which of the following best demonstrates the use of Optional with lambda expressions for safe null handling?

Q.199Hard

What is the return type of a lambda expression used with IntStream.range(1, 5).map(x -> x * 2)?

Q.200Hard

An enterprise application needs different bean implementations based on environment (dev/prod). Which approach is most suitable?