Skip to content
Sharp

Core Java · interview question

Which code correctly update the price of a product stored in a double variable?

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

Correct answer

A. Price += 10.0;

Why

The '+=' operator adds the specified value to the current value of the variable. Other options are syntactically incorrect.

Test yourself on Core Java

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

Start free test
All Core Java questions →