Skip to content
Sharp

Core Java · interview question

Which of the following is NOT a valid method declaration in Java?

Multiple choiceEasychapter-1-curatedpremiumcore-javamethods
Choose one answer
Answer and explanation

Correct answer

B. CalculateDiscount(double price, double rate)

Why

The option calculateDiscount(double price, double rate) is missing a return type. All methods must specify a return type, even if it is void.

Test yourself on Core Java

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

Start free test
All Core Java questions →