Skip to content
Sharp

Career Growth · interview question

In a concurrent Java application, what potential issue could arise from improper use of the 'volatile' keyword?

Multiple choiceHardchapter-20-curatedpremiumcareer-growthtransitioning-to-senior
java
class Counter { volatile int count; }
Choose one answer
Answer and explanation

Correct answer

D. Data consistency issues in complex operations

Why

The 'volatile' keyword ensures visibility of changes to variables across threads, but it doesn't guarantee atomicity for compound operations. This can lead to data consistency issues if the operations span multiple volatile variables or require synchronization.

Test yourself on Career Growth

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

Start free test
All Career Growth questions →