Skip to content
Sharp

Core Java · interview question

In an e-commerce application, why might it be problematic to use the same variable name for different purposes in a single method?

Multiple choiceHardchapter-1-curatedpremiumcore-javascope-and-reassignment
Choose one answer
Answer and explanation

Correct answer

C. It can lead to logical errors and confusion about which value is being used.

Why

Using the same variable name for different purposes can lead to confusion and logical errors, as it obscures which variable is being used at any point in the code. Clear naming conventions improve readability and maintenance.

Test yourself on Core Java

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

Start free test
All Core Java questions →