2V0-72.22PSE · Question #89
Refer to the exhibit. AppConfig is a Java configuration class. Which two statements are true? (Choose two.)
The correct answer is D. The bean is of type clientService and by default will be a Singleton. E. The Java configuration can be profile specific by adding a @Profile annotation. D is correct because Spring beans declared via @Bean in a @Configuration class are Singleton by default - the container creates exactly one instance and reuses it for every injection point. E is correct because @Profile can be applied to a @Configuration class (or individual…
Question
Refer to the exhibit. AppConfig is a Java configuration class. Which two statements are true? (Choose two.)
Exhibit
Options
- AThe clientService bean declared will have prototype scope by default.
- BThe name of the clientService() method is invalid and will throw an error.
- CThe clientService bean will be lazy initialized the first time accessed.
- DThe bean is of type clientService and by default will be a Singleton.
- EThe Java configuration can be profile specific by adding a @Profile annotation.
How the community answered
(53 responses)- A8% (4)
- B4% (2)
- C19% (10)
- D70% (37)
Explanation
D is correct because Spring beans declared via @Bean in a @Configuration class are Singleton by default - the container creates exactly one instance and reuses it for every injection point. E is correct because @Profile can be applied to a @Configuration class (or individual @Bean methods) to activate that configuration only when a matching Spring profile is active.
A is wrong because Singleton - not prototype - is the default scope; you'd need @Scope("prototype") explicitly. B is wrong because clientService is a perfectly valid camelCase Java method name and causes no errors. C is wrong because Spring beans are eagerly initialized at container startup by default; you'd need @Lazy to defer initialization until first access.
Memory tip: "Spring's default is Singleton, and Singletons are eager" - any deviation (prototype scope, lazy init) always requires an explicit annotation (@Scope, @Lazy). If the question says "by default," think Singleton + eager.
Topics
Community Discussion
No community discussion yet for this question.
