nerdexam
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)
  • A
    78% (25)
  • B
    13% (4)
  • D
    3% (1)
  • E
    6% (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.

Full 2V0-72.22 Practice