Skip to content
Sharp

Spring Core · interview question

Which annotation would you use to ensure a field is greater than zero?

Multiple choiceMediumchapter-9-curatedpremiumspring-corepersistence-and-validation
Choose one answer
Answer and explanation

Correct answer

A. @Positive

Why

The @Positive annotation ensures that the field is greater than zero. It's a straightforward way to enforce that a numeric field must be positive.

Test yourself on Spring Core

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

Start free test
All Spring Core questions →