D

Dhruva Jagannath • 660 Points
Invincible

Q. What will this code print?

Code:
enum Level { LOW, MEDIUM, HIGH }
System.out.println(Level.HIGH.ordinal());
  • (A) 1
  • (B) 2
  • (C) HIGH
  • (D) 0
  • Correct Answer - Option(B)
  • Views: 14
  • Filed under category Java
  • Hashtags: Java Enums

Explanation by: Dhruva Jagannath
`HIGH` is the third constant in the enum, so its ordinal is 2.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.