Skip to content
Sharp

Engineering Interviews · interview question

Which concurrency issue could arise from the following code snippet?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewscode-review-spotting-bugs
java
class Counter {
    private int count = 0;
    public void increment() {
        count++;
    }
}
Choose one answer
Answer and explanation

Correct answer

C. Race condition

Why

The code snippet may suffer from a race condition because multiple threads are modifying shared data without proper synchronization, leading to unpredictable outcomes.

Test yourself on Engineering Interviews

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

Start free test
All Engineering Interviews questions →