-
What is the output of below code snippet?
enum Enums
{
D, E, F;
private Enums()
{
System.out.println(20);
}
}
public class MainClass
{
public static void main(String[] args)
{
Enum en = Enums.E;
}
}
-
- Runtime Exception
- 20
- Compilation Error
- 10
- None of these
Correct Option: B
The constructor of Enums is called which prints 20.