Skip to content
Sharp

Spring Core · interview question

How can you ensure thread safety when using a Singleton bean?

Multiple choiceMediumchapter-9-curatedpremiumspring-corebean-scope
Choose one answer
Answer and explanation

Correct answer

B. Avoid using instance variables for storing state.

Why

To ensure thread safety in a Singleton bean, avoid using instance variables to store state. Instead, use method-local variables that are inherently thread-safe.

Test yourself on Spring Core

A free test with instant, explained results. No account needed.

Start free test
All Spring Core questions →