Which two statements are true concerning constructor injection? (Choose two.)
Options:
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:
A, C
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.
Question 3
Which two statements are true about REST? (Choose two.)