1. What is the output of this code?
Stream.of("a", "b", "c")
.map(String::toUpperCase)
.forEach(System.out::print);
- abc
B. ABC
C. a b c
D. Compilation Error
✅ Answer: B. ABC
2. Which of the following is a valid functional interface in Java 8?
- An interface with two abstract methods
B. An interface with one abstract method and multiple default methods
C. An interface with no methods
D. A class with one method
✅ Answer: B
3. What does Optional.empty() return?
- Null
B. Optional with null value
C. An Optional instance with no value present
D. Compilation error
✅ Answer: C
4. Which interface does Function<T, R> belong to?
- java.lang
B. java.io
C. java.util
D. java.util.function
✅ Answer: D
5. What is the purpose of Collectors.toList()?
- It converts a stream to a set
B. It terminates the stream
C. It collects stream elements into a list
D. It sorts a list
✅ Answer: C