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 39 discussion

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

Refer to the exhibit.

Based on the default Spring behavior, choose the correct answer. (Choose the best answer.)

  • A. One AccountRepository bean will be instantiated since the default scope is singleton.
  • B. Three AccountRepository beans will be instantiated as the accountRepository() method will be called three times.
  • C. Many AccountRepository beans will be instantiated, depending how often accountRepository(), transferService() and accountService() are called.
  • D. Two AccountRepository beans will be instantiated as the accountRepository() method will be called two times.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
Tolo01
5 months, 3 weeks ago
Selected Answer: A
A is the best answer
upvoted 2 times
...
rhuanca
10 months ago
why not D ? even if it is singleton because ther are no scope , the bean is still instantiated twice because it is called twice by two different @Bean methods (transferService() and accountService()).
upvoted 1 times
nesreenmhd123
3 months, 2 weeks ago
A. One AccountRepository bean will be instantiated since the default scope is singleton. In Spring, when a method annotated with @Bean is called multiple times within the same application context, the Spring container manages the bean instances based on the method's scope. By default, the scope of a @Bean method is singleton, which means Spring will create and manage a single instance of the bean within the application context. Regardless of how many times the method is called, only one instance of the bean will be created and managed by Spring.
upvoted 3 times
...
...
zakupower
10 months, 2 weeks ago
Selected Answer: A
Default scope is singleton, doesn't matter how many times you request the bean.
upvoted 3 times
quakquak3
1 month, 1 week ago
Also, Spring intercepts the call to the bean factory method and first checks if the singleton is already created. So it makes no difference if accountRepository() is called or if a parameter of type AccountRepository is used in transferService()/accountService()
upvoted 1 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