VMware vRealize Automation 8.x (2022) — Question 57
Which two mechanisms of autowiring a dependency when multiple beans match the dependency's type are correct? (Choose two.)
Answer options
- A. Use of @Qualifier annotation on the class and @Autowired annotation either on a field or setter methods.
- B. Use of @Qualifier and @Autowired annotations together with setter methods.
- C. Use of @Qualifier annotation only with setter methods (@Autowired is optional for setters).
- D. Use of @Qualifier and @Autowired annotations together on a field.
- E. Use of @Qualifier annotation only on a field (@Autowired is optional for fields).
Correct answer: B, D
Explanation
The correct answers are B and D because both options correctly demonstrate the use of @Qualifier with @Autowired in a way that resolves ambiguity when multiple beans of the same type exist. Options A, C, and E are incorrect as they either misplace the annotations or suggest that @Autowired is optional when it is necessary for proper dependency injection with @Qualifier.