Home » JAVA Programming » Basic Datatypes » Question
  1. 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;
    }
    }

    1. Runtime Exception
    2. 20
    3. Compilation Error
    4. 10
    5. None of these
Correct Option: B

The constructor of Enums is called which prints 20.



Your comments will be displayed only after manual approval.