Loading

Quipoin Menu

Learn • Practice • Grow

spring / Dependency Injection
mcq
Direction: Choose the correct option

Q1.

What is Dependency Injection?
A. A design pattern where objects receive their dependencies from an external source
B. A way to create objects directly
C. A database connection technique
D. A security mechanism
Direction: Choose the correct option

Q2.

Which type of Dependency Injection is supported by Spring?
A. Setter Injection
B. Constructor Injection
C. Field Injection
D. All of the above
Direction: Choose the correct option

Q3.

What is Inversion of Control (IoC)?
A. A principle where the control of object creation is inverted to a container
B. A programming language feature
C. A database concept
D. A security term
Direction: Choose the correct option

Q4.

Which annotation is used for constructor injection in Spring?
A. @Autowired on constructor
B. @Inject on constructor
C. Both A and B
D. @Resource on constructor
Direction: Choose the correct option

Q5.

What is the advantage of constructor injection over field injection?
A. Immutability
B. Easier testing
C. Clear dependencies
D. All of the above
Direction: Choose the correct option

Q6.

Which Spring annotation is equivalent to @Inject from JSR-330?
A. @Autowired
B. @Resource
C. @Qualifier
D. @Component
Direction: Choose the correct option

Q7.

What does the @Qualifier annotation do?
A. Specifies which bean to inject when multiple candidates exist
B. Marks a bean as primary
C. Defines a bean name
D. None of the above
Direction: Choose the correct option

Q8.

Which type of injection is most recommended by Spring team?
A. Field injection
B. Setter injection
C. Constructor injection
D. Method injection
Direction: Choose the correct option

Q9.

What is the role of @Primary annotation?
A. Indicates that a bean should be given preference when multiple candidates qualify
B. Marks a bean as lazy
C. Defines the bean scope
D. None
Direction: Choose the correct option

Q10.

What happens if no qualifying bean is found for autowiring?
A. Spring throws NoSuchBeanDefinitionException
B. Spring creates a proxy
C. The application starts with null dependency
D. It depends on configuration