Which two statements are true concerning constructor injection? (Choose two.)
A . If there is only one constructor the @Autowired annotation is not required.
B . Constructor injection only allows one value to be injected.
C . Constructor injection is preferred over field injection to support unit testing.
D . Construction injection can be used with multiple constructors without @Autowired annotation.
E . Field injection is preferred over constructor injection from a unit testing standpoint.
Answer: AC
Explanation:
Constructor injection is one of the ways to inject dependencies into a bean using its constructor parameters. Since Spring 4.3, if a bean has only one constructor, the @Autowired annotation can be omitted and Spring will use that constructor by default.
Constructor injection is generally recommended over field injection because it makes the dependencies of a bean explicit and immutable. It also facilitates unit testing because it allows us to easily provide mock dependencies through constructor arguments.
Latest 2V0-72.22 Dumps Valid Version with 60 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund