Bird
0
0

Which of the following is the correct way to register a service in a dependency injection framework?

easy📝 Conceptual Q12 of 15
LLD - Advanced LLD Concepts
Which of the following is the correct way to register a service in a dependency injection framework?
Ainjector.register(ServiceClass)
BServiceClass.inject()
Cregister.injector(ServiceClass)
DServiceClass.register()
Step-by-Step Solution
Solution:
  1. Step 1: Recall the registration syntax

    In most dependency injection frameworks, you register a service by calling a method on the injector object and passing the service class.
  2. Step 2: Match the correct syntax

    The correct syntax is injector.register(ServiceClass), which tells the injector to manage that service.
  3. Final Answer:

    injector.register(ServiceClass) -> Option A
  4. Quick Check:

    Register service = injector.register() [OK]
Quick Trick: Register services by calling register on the injector [OK]
Common Mistakes:
  • Calling register on the service class instead of injector
  • Mixing method order or names
  • Using non-existent methods like inject() on service

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes