Govt Exams
This is a curried function. curry.apply(5) returns a function that adds 5. Applying that with 3 gives 5 + 3 = 8.
Each flatMap creates intermediate streams. Deeply nested flatMap with lambdas can consume significant memory, especially with large datasets.
Collectors.toMap with key mapper (s -> s) produces String keys and value mapper (s -> s.length()) produces Integer values, resulting in Map<String, Integer>.
Sequential reduce is O(n). Parallel reduction can be O(log n) with a properly associative and commutative operation, enabling divide-and-conquer approach.
Lambda expressions don't propagate checked exceptions. They must be caught within the lambda body using try-catch.
range(1, 4) generates [1, 2, 3]. After map(x -> x * 2): [2, 4, 6]. Sum = 2 + 4 + 6 = 12.
The Comparator<T> functional interface has the method compare(T a, T b) which returns an int, matching this lambda's behavior.
peek() is an intermediate operation used for debugging; it doesn't end the stream. forEach() is a terminal operation that consumes the stream.
Method reference (::) is syntactic sugar for lambda expressions. System.out::println is equivalent to x -> System.out.println(x).
Both collect() and forEach() are valid terminal operations. collect() returns a list, forEach() performs an action. reduce() is also valid but would sum the squares.