Skip to content
Sharp

Reactive Streams · interview question

How does the flatMap operator differ from map in Project Reactor's Flux?

Multiple choiceMediumchapter-19-curatedpremiumreactive-streamsbackpressure-strategies
java
Flux.just(1, 2, 3).flatMap(i -> Flux.just(i * i));
Choose one answer
Answer and explanation

Correct answer

D. flatMap can handle asynchronous operations and flatten them.

Why

The flatMap operator is used for asynchronous transformations and flattens Publisher<Publisher<T>> into Publisher<T>, allowing concurrent operations and handling nested streams effectively.

Test yourself on Reactive Streams

A free test with instant, explained results. No account needed.

Start free test
All Reactive Streams questions →