A service cannot work without its repository and payment client. What injection style gives the clearest fail-fast design?

Practice this question from Quiz: Spring Core, with options and an explanation.

Question

A service cannot work without its repository and payment client. What injection style gives the clearest fail-fast design?

Option A — Correct answer

Constructor injection

Required dependencies should be constructor parameters.

Option B

Random static lookup

Option C

Manual reflection only

Option D

Public mutable fields

Explanation

Constructor injection makes required dependencies explicit and supports immutable fields.

Quiz: Spring Core

All questions · Previous question · Next question

Open on QuizMaker