Skip to content
Sharp

Core Java · interview question

Which of the following variable names is best for storing the total amount in a shopping cart?

Multiple choiceMediumchapter-1-curatedpremiumcore-javavariables-and-data-types
Choose one answer
Answer and explanation

Correct answer

D. CartTotal

Why

The name 'cartTotal' is descriptive and clear, indicating the purpose of the variable. Good variable naming improves code readability and maintainability.

Test yourself on Core Java

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

Start free test
All Core Java questions →