Broadcom-VMware
2V0-72.22 · Question #68
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…
The correct answer is B. @Autowired @Qualifier ("foo3") Foo foo; C. @Autowired public void setFoo (@Qualifier ("foo1") Foo foo) {...} E. @Autowired private Foo foo2. See the full explanation below for the reasoning.
Question
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.)
Options
- A@Autowired public void setFoo (Foo foo) {...}
- B@Autowired @Qualifier ("foo3") Foo foo;
- C@Autowired public void setFoo (@Qualifier ("foo1") Foo foo) {...}
- D@Autowired private Foo foo;
- E@Autowired private Foo foo2;
- F@Autowired public void setFoo(Foo foo2) {...}
How the community answered
(32 responses)- A3% (1)
- B78% (25)
- D13% (4)
- F6% (2)
Community Discussion
No community discussion yet for this question.