Skip to content
Sharp

Spring Core · interview question

How can you specify a default value for a property in Spring when using the @Value annotation?

Multiple choiceEasychapter-9-curatedpremiumspring-coreapplication-properties
Choose one answer
Answer and explanation

Correct answer

D. @Value("${property.name:defaultValue}")

Why

You can specify a default value for a property using the @Value annotation by providing it in the format: @Value("${property.name:defaultValue}").

Test yourself on Spring Core

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

Start free test
All Spring Core questions →