Loading

Quipoin Menu

Learn • Practice • Grow

angular / Dependency Injection
mcq
Direction: Choose the correct option

Q1.

What is dependency injection in Angular?
A. A method for HTTP requests
B. A pattern where a class receives its dependencies from an external source
C. A routing technique
D. A way to create new objects
Direction: Choose the correct option

Q2.

What is an injector in Angular?
A. A service that injects data
B. A component that receives injections
C. An object that creates and manages dependencies
D. A module that provides services
Direction: Choose the correct option

Q3.

How do you inject a service into a component?
A. Using @Inject decorator
B. Using @Injectable
C. Using a setter
D. Via constructor parameters
Direction: Choose the correct option

Q4.

What is the role of providers in DI?
A. They provide HTTP requests
B. They provide data to services
C. They tell Angular how to create a dependency
D. They provide routing
Direction: Choose the correct option

Q5.

What is a hierarchical injector?
A. Injectors arranged in a tree matching the component hierarchy
B. An injector for services only
C. A single global injector
D. An injector for modules only
Direction: Choose the correct option

Q6.

What is the `@Injectable` decorator's role in DI?
A. Injects dependencies
B. Configures DI
C. Marks a class as available to be injected with its own dependencies
D. Creates a service
Direction: Choose the correct option

Q7.

What is a provider token?
A. A token for authentication
B. An identifier used to look up a dependency
C. A routing token
D. A security token
Direction: Choose the correct option

Q8.

What is `@Optional` decorator used for?
A. Marks a dependency as optional; Angular returns null if not found
B. Skips injection
C. Makes a dependency optional
D. Ignores errors
Direction: Choose the correct option

Q9.

What is `@Self` decorator?
A. Creates self
B. Injects self
C. References self
D. Limits DI resolution to the current injector
Direction: Choose the correct option

Q10.

What is `@SkipSelf` decorator used for?
A. Skips self injection
B. Tells DI to skip the current injector and look up the hierarchy
C. Skips providers
D. Skips errors