Bird
0
0

How does field injection negatively affect the principle of explicit dependencies in Spring Boot applications?

hard📝 Application Q9 of 15
Spring Boot - Inversion of Control and Dependency Injection
How does field injection negatively affect the principle of explicit dependencies in Spring Boot applications?
AIt requires dependencies to be public fields, exposing internal state
BIt forces all dependencies to be passed via constructor parameters
CIt automatically documents dependencies in class signatures
DIt hides dependencies inside private fields, making them implicit and harder to track
Step-by-Step Solution
Solution:
  1. Step 1: Define explicit dependencies principle

    Explicit dependencies mean all required components are clearly visible in class constructors or methods.
  2. Step 2: Analyze field injection effect

    Field injection hides dependencies inside private fields, making them implicit and less obvious to readers.
  3. Final Answer:

    It hides dependencies inside private fields, making them implicit and harder to track -> Option D
  4. Quick Check:

    Field injection hides dependencies = C [OK]
Quick Trick: Explicit dependencies should be visible, field injection hides them [OK]
Common Mistakes:
  • Thinking field injection forces constructor parameters
  • Believing field injection requires public fields
  • Assuming field injection documents dependencies automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes