Exam 2V0-72.22 Topic 2 Question 24 Discussion
Actual exam question for VMware's 2V0-72.22 exam
Question #: 24
Topic #: 2
Question #: 24
Topic #: 2
Which two statements about the @Autowired annotation are true? (Choose two.)
Suggested Answer: B,C Vote an answer
BeanFactoryPostProcessor.
Explanation:
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html B . Multiple arguments can be injected into a single method using @Autowired.
This is true because the @Autowired annotation can be applied to methods with arbitrary names and multiple arguments, as shown in the example in Using @Autowired.
C . By default, if a dependency cannot be satisfied with @Autowired, Spring throws a RuntimeException.
This is true because the @Autowired annotation has a required attribute that is true by default, meaning that the dependency is mandatory. If Spring cannot find a matching bean to inject, it will throw a BeanCreationException, which is a subclass of RuntimeException. To avoid this exception, we can set the required attribute to false, which will allow Spring to skip the injection if no matching bean is found
Explanation:
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html B . Multiple arguments can be injected into a single method using @Autowired.
This is true because the @Autowired annotation can be applied to methods with arbitrary names and multiple arguments, as shown in the example in Using @Autowired.
C . By default, if a dependency cannot be satisfied with @Autowired, Spring throws a RuntimeException.
This is true because the @Autowired annotation has a required attribute that is true by default, meaning that the dependency is mandatory. If Spring cannot find a matching bean to inject, it will throw a BeanCreationException, which is a subclass of RuntimeException. To avoid this exception, we can set the required attribute to false, which will allow Spring to skip the injection if no matching bean is found
by rntsol at Apr 22, 2025, 10:22 AM
0
0
0
10
Comments
rntsol
2025-04-22 10:22:25Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).