Skip to content
Sharp

Dependency Injection · interview question

Why is using @Autowired on constructor parameters recommended in Spring Boot?

Multiple choiceEasychapter-9-curatedpremiumdependency-injectionconstructor-vs-field-injection
Choose one answer
Answer and explanation

Correct answer

D. It explicitly defines required dependencies

Why

Using @Autowired on constructor parameters is recommended because it explicitly defines the required dependencies of a class, making the code more readable and ensuring that all necessary dependencies are provided during object creation.

Test yourself on Dependency Injection

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

Start free test
All Dependency Injection questions →