Skip to content
Sharp

Engineering Interviews · interview question

Which Java feature helps ensure no two threads can access critical sections of code simultaneously?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewscode-review-spotting-bugs
Choose one answer
Answer and explanation

Correct answer

B. Synchronized keyword

Why

The synchronized keyword is used to lock critical sections of code, ensuring that only one thread can execute the block at a time, which helps prevent concurrent access issues.

Test yourself on Engineering Interviews

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

Start free test
All Engineering Interviews questions →