← Quiz: Spring Core and DI: all 10 questions
Quiz: Spring Core and DI · Question 8 of 10
Why is it dangerous to store per-user data in a field of a singleton service bean?
Why is it dangerous to store per-user data in a field of a singleton service bean?
- A.Singleton beans cannot have fields
- B.The field is reset after every request
- C.Spring forbids it at startup
- D.One instance is shared by all threads, so users would overwrite each other's data
Answer & explanation
Correct answer: One instance is shared by all threads, so users would overwrite each other's data
Singletons are shared; keep request data in local variables or parameters.
Can you get the rest right without peeking?
Take the timed Quiz: Spring Core and DI quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →