Skip to content
Sharp

Core Java · interview question

Which Scanner method is best for reading a price input as a floating-point number in a console-based e-commerce application?

Multiple choiceEasychapter-1-curatedpremiumcore-javaconsole-input-and-output
Choose one answer
Answer and explanation

Correct answer

C. NextDouble()

Why

The nextDouble() method is designed to read input as a double type, which is suitable for prices that require decimal points.

Test yourself on Core Java

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

Start free test
All Core Java questions →