Skip to content
Sharp

Core Java · interview question

Which Scanner method would you use to read a floating-point number from the console?

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

Correct answer

C. NextDouble()

Why

The 'nextDouble()' method of the Scanner class is used to read a floating-point number from the console with double precision, suitable for handling currency values in an e-commerce application.

Test yourself on Core Java

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

Start free test
All Core Java questions →