Question
Which statement about map, flatMap, and reduce is the strongest interview answer?
- map, flatMap, and reduce is mostly a naming style choice and has little effect on runtime or design.
- map transforms each element, flatMap transforms and flattens nested results, and reduce combines many values into one.
- map, flatMap, and reduce exists mainly to reduce the number of Java files in a project.
- map, flatMap, and reduce matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind map, flatMap, and reduce.
Answer and rationale
Correct answer: B. map transforms each element, flatMap transforms and flattens nested results, and reduce combines many values into one.
map transforms each element, flatMap transforms and flattens nested results, and reduce combines many values into one. This is the base concept interviewers commonly test first.
Track: Java