Broadcom-VMware
2V0-72.22PSE · 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
(52 responses)- A88% (46)
- B4% (2)
- D6% (3)
- E2% (1)
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#@Autowired#dependency injection#unit testing
Community Discussion
No community discussion yet for this question.