D

Dhruva Jagannath • 660 Points
Invincible

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

  • (A) The name of the constant
  • (B) The position of the constant in the enum declaration
  • (C) The hashcode of the constant
  • (D) The string value of the enum
  • Correct Answer - Option(B)
  • Views: 28
  • Filed under category Java
  • Hashtags: Java Enums

Explanation by: Dhruva Jagannath

`ordinal()` returns the position (zero-based index) of the enum constant in its declaration.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.