Loading

Quipoin Menu

Learn • Practice • Grow

spring / Autowiring in Spring
mcq
Direction: Choose the correct option

Q1.

What is autowiring in Spring?
A. Automatic dependency injection
B. Automatic bean creation
C. Automatic configuration
D. Automatic method invocation
Direction: Choose the correct option

Q2.

Which modes of autowiring are available in XML configuration?
A. byName
B. byType
C. constructor
D. All of the above
Direction: Choose the correct option

Q3.

What is the default autowiring mode in modern Spring (annotation-based)?
A. no
B. byType
C. byName
D. constructor
Direction: Choose the correct option

Q4.

How does autowiring 'byName' work?
A. Matches bean id with property name
B. Matches bean type with property type
C. Matches constructor arguments
D. Matches annotations
Direction: Choose the correct option

Q5.

What happens if autowiring 'byType' finds multiple beans of the same type?
A. Spring throws an exception
B. Spring picks the primary bean
C. Spring uses @Qualifier
D. All of the above
Direction: Choose the correct option

Q6.

Which annotation enables autowiring in Spring?
A. @Autowired
B. @Inject
C. @Resource
D. All of the above
Direction: Choose the correct option

Q7.

What is the difference between @Autowired and @Resource?
A. @Autowired by type, @Resource by name
B. @Autowired by name, @Resource by type
C. Both are same
D. @Autowired is newer
Direction: Choose the correct option

Q8.

Can autowiring be used on methods?
A. Yes, on setter methods and any arbitrary method
B. No, only on fields and constructors
C. Only on constructors
D. Only on fields
Direction: Choose the correct option

Q9.

What is the purpose of @Autowired(required=false)?
A. Makes autowiring optional; no exception if dependency not found
B. Makes bean mandatory
C. Disables autowiring
D. Sets dependency as lazy
Direction: Choose the correct option

Q10.

Which annotation can be used to inject a bean by its name?
A. @Qualifier
B. @Resource(name='...')
C. @Autowired with @Qualifier
D. All of the above