Exam 2v0-7222 All QuestionsBrowse all questions from this exam
Question 32

Refer to the exhibit.

It is a Java code fragment from a Spring application. Which statement is true with regard to the above example? (Choose the best answer.)

    Correct Answer: D

    The method applicationContext.getBean(ClientService.class) is used to retrieve a bean from the Spring application context based on its type. Therefore, it will return a bean of the type ClientService regardless of its id or name.

Discussion
AzuniOption: D

The answer is correct. Just remember though that you can fetch it with bean name, class or both (which was a surprise to me). https://www.baeldung.com/spring-getbean#3-retrieving-bean-by-type