nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #11

Refer to the exhibit. What is the id/name of the declared bean in this Java configuration class? (Choose the best answer.)

The correct answer is C. clientService (starting with lowercase "c"). Option C is correct because in a Spring @Configuration class, a @Bean method's name determines the bean id, not the return type or implementation class. The exhibit shows a method named clientService(), so Spring registers the bean with the id clientService (lowercase "c") by…

Core Spring

Question

Refer to the exhibit. What is the id/name of the declared bean in this Java configuration class? (Choose the best answer.)

Options

  • AclientServiceImpl (starting with lowercase "c")
  • BclientServiceImpl (starting with uppercase "C")
  • CclientService (starting with lowercase "c")
  • DClientService (starting with uppercase "C")

How the community answered

(43 responses)
  • A
    2% (1)
  • B
    7% (3)
  • C
    86% (37)
  • D
    5% (2)

Explanation

Option C is correct because in a Spring @Configuration class, a @Bean method's name determines the bean id, not the return type or implementation class. The exhibit shows a method named clientService(), so Spring registers the bean with the id clientService (lowercase "c") by default.

Why the distractors are wrong:

  • A & B (clientServiceImpl): The implementation class name is irrelevant to the bean id - Spring uses the method name, not the class being instantiated inside the method.
  • D (ClientService with uppercase "C"): The return type (interface or class) also does not determine the bean name; again, it's the method name that matters.

Memory tip: Think of the @Bean method name as the bean's "nickname" in the Spring container - whatever you call the method is what you use to look up the bean. If you want a different name, you must explicitly set it with @Bean(name = "myCustomName").

Topics

#Bean naming conventions#@Bean annotation#Spring configuration#Method names

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice