Skip to content
Sharp

Project Reactor · interview question

If a Mono completes empty, which of the following methods can be used to provide a default value?

Multiple choiceHardchapter-19-curatedpremiumproject-reactorproject-reactor-mono
Choose one answer
Answer and explanation

Correct answer

A. Mono.defaultIfEmpty(T defaultValue)

Why

Mono.defaultIfEmpty(T defaultValue) is used to provide a default value when the Mono completes without emitting any item. This ensures that a non-empty result is always obtained from the Mono.

Test yourself on Project Reactor

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

Start free test
All Project Reactor questions →