Broadcom-VMware
2V0-72.22 · Question #67
Which two statements are true concerning constructor injection? (Choose two.)
The correct answer is A. If there is only one constructor the @Autowired annotation is not required. C. Constructor injection is preferred over field injection to support unit testing. As of Spring Framework 4.3, an @Autowired annotation on such a constructor is no longer necessary if the target bean only defines one constructor to begin with.
Core Spring
Question
Which two statements are true concerning constructor injection? (Choose two.)
Options
- AIf there is only one constructor the @Autowired annotation is not required.
- BConstructor injection only allows one value to be injected.
- CConstructor injection is preferred over field injection to support unit testing.
- DConstruction injection can be used with multiple constructors without @Autowired annotation.
- EField injection is preferred over constructor injection from a unit testing standpoint.
How the community answered
(32 responses)- A78% (25)
- B13% (4)
- D3% (1)
- E6% (2)
Explanation
As of Spring Framework 4.3, an @Autowired annotation on such a constructor is no longer necessary if the target bean only defines one constructor to begin with.
Topics
#constructor injection#field injection#@Autowired#dependency injection
Community Discussion
No community discussion yet for this question.