🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Singleton beans cannot have fields
  2. B.The field is reset after every request
  3. C.Spring forbids it at startup
  4. 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 →