Skip to content
Sharp

Spring Core · interview question

Which annotation would you use to ensure that a field in a Spring Boot controller method is not blank?

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

Correct answer

D. @NotBlank

Why

The @NotBlank annotation ensures that a string is not null, and not just whitespace. It is specifically used for strings, while @NotNull and @NotEmpty have different uses.

Test yourself on Spring Core

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

Start free test
All Spring Core questions →