Intermediate
Web & Software Development
Q45 / 100
What is dependency injection (DI)?
Correct! Well done.
Incorrect.
The correct answer is B) A design pattern providing a class its dependencies from outside (via constructor, setter, or interface) rather than having the class create them
B
Correct Answer
A design pattern providing a class its dependencies from outside (via constructor, setter, or interface) rather than having the class create them
Explanation
DI: class declares what it needs; a DI container or caller provides it. Enables loose coupling and testability (inject mocks). DI containers (Spring, Dagger, Autofac) manage object graphs automatically.
Progress
45/100