U.S. Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

VMware 2V0-72.22 Exam - Topic 1 Question 89 Discussion

Given an ApplicationContext containing three bean definitions of type Foo with bean ids foo1, foo2, and foo3, which three @Autowired scenarios are valid and will allow the ApplicationContext to initialize successfully? (Choose three.)
B) @Autowired @Qualifier (''foo3'') Foo foo; and C) @Autowired public void setFoo (@Qualifier (''foo1'') Foo foo) {...} and F) @Autowired public void setFoo(Foo foo2) {...}
A) @Autowired public void setFoo (Foo foo) {...}
D) @Autowired private Foo foo;
E) @Autowired private Foo foo2;

VMware 2V0-72.22 Exam - Topic 1 Question 89 Discussion

Actual exam question for VMware's 2V0-72.22 exam
Question #: 89
Topic #: 1
[All 2V0-72.22 Questions]

Given an ApplicationContext containing three bean definitions of type Foo with bean ids foo1, foo2, and foo3, which three @Autowired scenarios are valid and will allow the ApplicationContext to initialize successfully? (Choose three.)

Show Suggested Answer Hide Answer
Suggested Answer: B, C, F

The @Autowired annotation can be used to inject a dependency into a field, a constructor, or a setter method. However, if there are multiple beans of the same type in the application context, Spring will not be able to determine which one to inject by default. To resolve this ambiguity, we can use the @Qualifier annotation to specify the bean id of the desired dependency. Alternatively, we can use the bean id as the name of the field or the parameter of the setter method, and Spring will match it with the corresponding bean.


Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel