← Quiz: SOLID Principles: all 10 questions
Quiz: SOLID Principles · Question 4 of 10
Passing a database object into a service's constructor instead of creating it inside is an example of:
Passing a database object into a service's constructor instead of creating it inside is an example of:
- A.Inheritance
- B.Dependency injection (to follow Dependency Inversion)
- C.Interface segregation
- D.Encapsulation only
Answer & explanation
Correct answer: Dependency injection (to follow Dependency Inversion)
The service depends on an abstraction that is given to it.
Can you get the rest right without peeking?
Take the timed Quiz: SOLID Principles quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →