Module: | Multithreading, Collections & I/O Streams
Q69: Consider the following statements regarding the Iterable forEach method:
1. Java 8 heavily modified the fundamental java.lang.Iterable interface by adding a default forEach() method, granting internal iteration capabilities directly to standard Collections.
2. The forEach() method strictly mandates the developer to pass a Predicate functional interface to mathematically dictate the exact iteration sequence.
3. Utilizing forEach() in conjunction with a method reference (e.g., list.forEach(System.out::println)) is structurally identical to using a lambda expression but offers superior syntactical conciseness.
Which of the above statements is/are correct?
2. The forEach() method strictly mandates the developer to pass a Predicate functional interface to mathematically dictate the exact iteration sequence.
3. Utilizing forEach() in conjunction with a method reference (e.g., list.forEach(System.out::println)) is structurally identical to using a lambda expression but offers superior syntactical conciseness.
Which of the above statements is/are correct?
✅ Correct Answer: B