Skip to content
Sharp

Modern Java · interview question

What does the ordinal() method of an enum return?

Multiple choiceEasychapter-7-curatedpremiummodern-javaenums
Choose one answer
Answer and explanation

Correct answer

C. The position of the constant in the enum declaration

Why

The ordinal() method returns the position of the enum constant, starting from 0, based on the order they are declared within the enum type.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →