Loading
Java Enumeration -interview

Q1.  Can enums implement interfaces?

Yes, enums can implement interfaces but cannot extend classes since they implicitly extend java.lang.Enum.





Q2.  How do you declare an enum in Java?

Enums are declared using the enum keyword.


enum Day {

        MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY

    }





Q3. Can enums have methods and constructors?

Yes. Enums can have methods, variables, and constructors. Constructors in enums are always private and cannot be called explicitly.






Q4. What is the default superclass of all enums in Java?

Every enum in Java implicitly extends the java.lang.Enum class.






Q5. How are enums different from constants defined with final static variables?

Enums provide type safety, can have methods, and are more readable compared to final static constants. They are also iterable and can be used in switch statements.