VMware vRealize Automation 8.x (2022) — Question 31
Which two statements are true regarding bean creation? (Choose two.)
Answer options
- A. A Spring bean can be explicitly created by annotating methods or fields by @Autowired.
- B. A Spring bean can be implicitly created by annotating the class with @Component and using the component-scanner to scan its package.
- C. A Spring bean can be implicitly created by annotating the class with @Bean and using the component-scanner to scan its package.
- D. A Spring bean can be explicitly created using @Bean annotated methods within a Spring configuration class.
- E. A Spring bean can be explicitly created by annotating the class with @Autowired.
Correct answer: B, D
Explanation
Option B is correct because a Spring bean can indeed be created automatically by using the @Component annotation along with component scanning. Option D is also correct as it allows for explicit bean creation using methods annotated with @Bean in configuration classes. Options A, C, and E are incorrect because @Autowired is used for dependency injection, not for bean creation, and @Bean does not require the component-scanner to create beans.