A

Admin • 802.91K Points
Coach

Q. What will be the output of the following code?

Code:
enum Day { MONDAY, TUESDAY }
System.out.println(Day.MONDAY.ordinal());
  • (A) 1
  • (B) 0
  • (C) MONDAY
  • (D) Error

Explanation by: Admin
`ordinal()` returns the position of the constant in the enum declaration, starting from 0. So MONDAY has ordinal 0.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.