nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #52

Which two statements about the @Autowired annotation are true? (Choose two.)

The correct answer is B. Multiple arguments can be injected into a single method using @Autowired. C. By default, if a dependency cannot be satisfied with @Autowired, Spring throws a. B is correct because @Autowired can be placed on a method with multiple parameters, and Spring resolves each parameter independently from the application context - e.g., @Autowired public void init(ServiceA a, ServiceB b) works fine. C is correct because @Autowired defaults to…

Core Spring

Question

Which two statements about the @Autowired annotation are true? (Choose two.)

Options

  • A@Autowired fields are injected after any config methods are invoked.
  • BMultiple arguments can be injected into a single method using @Autowired.
  • CBy default, if a dependency cannot be satisfied with @Autowired, Spring throws a
  • DIf @Autowired is used on a class, field injection is automatically performed for all
  • E@Autowired can be used to inject references into BeanPostProcessor and

How the community answered

(27 responses)
  • B
    96% (26)
  • E
    4% (1)

Explanation

B is correct because @Autowired can be placed on a method with multiple parameters, and Spring resolves each parameter independently from the application context - e.g., @Autowired public void init(ServiceA a, ServiceB b) works fine.

C is correct because @Autowired defaults to required = true, so if Spring cannot find a matching bean, it throws an UnsatisfiedDependencyException. You must explicitly set @Autowired(required = false) to make injection optional.

A is wrong - the injection order is actually constructor → fields → methods, so @Autowired fields are injected before config methods, not after. D is wrong - @Autowired is not a class-level annotation that auto-injects all fields; each field (or constructor/method) must be individually annotated. E is wrong - BeanPostProcessor and BeanFactoryPostProcessor are instantiated very early in the Spring lifecycle, before regular beans are ready, so @Autowired injection into them is unreliable and unsupported.

Memory tip: Think "Big Crash" - @Autowired handles Big (multi-arg) methods and Crashes by default when a bean is missing. If you remember that it's strict by default and flexible with method parameters, B and C fall naturally into place.

Topics

#Autowired annotation#Dependency injection#Bean wiring#Spring exceptions

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice