Skip to content
Sharp

Spring Core · interview question

How can you ensure thread safety when using a singleton-scoped bean in Spring?

Multiple choiceHardchapter-9-curatedpremiumspring-coreinversion-of-control-ioc
Choose one answer
Answer and explanation

Correct answer

D. By using synchronized methods.

Why

To ensure thread safety with singleton-scoped beans, you can use synchronized methods or blocks to control access to shared resources or modify state safely. This prevents concurrent access issues in a multi-threaded environment.

Test yourself on Spring Core

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

Start free test
All Spring Core questions →