What will this code print?

  1. 1
  2. 2
  3. HIGH
  4. 0
Correct answer 2

Explanation

`HIGH` is the third constant in the enum, so its ordinal is 2.

Update: Dhruva Jagannath added a tag on this question

Code

enum Level { LOW, MEDIUM, HIGH }
System.out.println(Level.HIGH.ordinal());

Topics

By Dhruva Jagannath · · 35 views