Skip to content
Sharp

Spring Core · interview question

Why do teams use constructor injection in a Spring Boot application in production code?

Multiple choiceMediumchapter-9-curatedpremiumspring-coredtos-and-entities
Choose one answer
Answer and explanation

Correct answer

A. It ensures immutability of the injected fields.

Why

Constructor injection enforces dependencies to be initialized at creation time, potentially allowing fields to be marked final, thus ensuring immutability.

Test yourself on Spring Core

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

Start free test
All Spring Core questions →