Skip to content
Sharp

Dependency Injection · interview question

How would you explain a key benefit of using constructor injection with 'final' fields in Spring Boot in an interview?

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

Correct answer

C. It ensures all dependencies are injected at once

Why

Constructor injection with 'final' fields ensures that all dependencies are injected and fully initialized when the object is constructed, preventing partially constructed states and enhancing code reliability.

Test yourself on Dependency Injection

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

Start free test
All Dependency Injection questions →