Skip to content
Sharp

Core Java · interview question

Why split checkout math into named values like subtotal, discountAmount, and finalTotal instead of writing one long expression?

Multiple choiceMediumchapter-1-curatedpremiumcore-javaoperators-and-expressions
Choose one answer
Answer and explanation

Correct answer

D. It makes the logic easier to read, trace, and debug

Why

Named intermediate values make business logic easier to inspect. They also create checkpoints for debugging, which is especially useful when a final checkout total looks wrong.

Test yourself on Core Java

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

Start free test
All Core Java questions →