Govt. Exams
Entrance Exams
Advertisement
Topics in Java Programming
What happens when a prototype-scoped bean has a dependency on a singleton-scoped bean in Spring?
Correct Answer:
B. The singleton bean is correctly injected into each prototype instance
EXPLANATION
A prototype bean can depend on singleton beans without issues. Each prototype instance gets the same singleton instance injected. The reverse (singleton depending on prototype) is problematic.
An enterprise application needs different bean implementations based on environment (dev/prod). Which approach is most suitable?
Correct Answer:
C. @Profile annotation to define environment-specific beans
EXPLANATION
@Profile allows defining beans for specific environments (dev, prod, test). Alternatively, @Conditional provides more granular control with custom conditions.