exam questions

Exam 2V0-72.22 All Questions

View all questions & answers for the 2V0-72.22 exam

Exam 2V0-72.22 topic 1 question 25 discussion

Actual exam question from VMware's 2V0-72.22
Question #: 25
Topic #: 1
[All 2V0-72.22 Questions]

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

  • A. @Autowired fields are injected after any config methods are invoked.
  • 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 RuntimeException.
  • D. If @Autowired is used on a class, field injection is automatically performed for all dependencies.
  • E. @Autowired can be used to inject references into BeanPostProcessor and BeanFactoryPostProcessor.
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Azuni
Highly Voted 7 months, 2 weeks ago
Selected Answer: BC
B is of course correct, but the reason why C is correct is because the default required setting of Autowired is 'true'. If no bean is found, a org.springframework.beans.factory.NoSuchBeanDefinitionException is thrown, which is a RuntimeException.
upvoted 6 times
Azuni
7 months ago
A is not correct as the Fields are injected right after construction of a bean, before any config methods are invoked. D is incorrect as you can't annotate a class. E is incorrect as Autowired is not supported in BeanPostProcessor or BeanFactoryPostProcessor, so you can't inject a reference in them using Autowired. Here is my reference: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html
upvoted 1 times
...
...
Tolo01
Most Recent 7 months, 3 weeks ago
Selected Answer: BC
B and C
upvoted 2 times
...
qqoo
8 months, 1 week ago
Selected Answer: AB
The others seem wrong
upvoted 1 times
...
rhuanca
11 months, 2 weeks ago
B and C
upvoted 1 times
...
qulyt
1 year, 2 months ago
A and B, per Autowired documentation. Autowired Fields Fields are injected right after construction of a bean, before any config methods are invoked. Such a config field does not have to be public. Autowired Methods Config methods may have an arbitrary name and any number of arguments; each of those arguments will be autowired with a matching bean in the Spring container. Bean property setter methods are effectively just a special case of such a general config method. Such config methods do not have to be public.
upvoted 1 times
rhuanca
11 months, 2 weeks ago
Not sure about A, because @Autowired fields are injected before any config methods (@Bean, @Component, @Configuration, etc..) are invoked.
upvoted 1 times
...
...
faciorys
1 year, 3 months ago
E is not correct Note that actual injection is performed through a BeanPostProcessor which in turn means that you cannot use @Autowired to inject references into BeanPostProcessor or BeanFactoryPostProcessor types. Please consult the javadoc for the AutowiredAnnotationBeanPostProcessor class (which, by default, checks for the presence of this annotation). https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting 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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago