Skip to content
Sharp

Engineering Interviews · interview question

Which Java language feature ensures that a volatile variable is visible across threads?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewsjvm-trivia
Choose one answer
Answer and explanation

Correct answer

D. Volatile keyword

Why

The volatile keyword ensures that a variable's updates are immediately visible to all threads, preventing thread-local caching of the variable and ensuring memory consistency.

Test yourself on Engineering Interviews

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

Start free test
All Engineering Interviews questions →