Skip to content
Sharp

Concurrency basics · interview question

How does the 'synchronized' keyword affect instance and static methods differently?

Multiple choiceMediumchapter-15-curatedpremiumconcurrencysynchronized-and-locks
Choose one answer
Answer and explanation

Correct answer

C. Instance methods lock the object, static methods lock the class

Why

When 'synchronized' is used on an instance method, it locks the object instance, preventing other synchronized instance methods from executing concurrently on the same object. For static methods, it locks the entire class, preventing concurrent execution across all instances.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →