9 Matching Annotations
  1. Jan 2022
    1. enum can contain both concrete methods and abstract methods. If an enum class has an abstract method, then each instance of the enum class must implement it 

      Yet to explore abstract methods for java enums

    2. We can’t create enum objects explicitly and hence we can’t invoke enum constructor directly.

      Color c1 = Color.RED;

      Color is the enum and "RED" is internally a class object of class "Color".

      In which language though, can invoke the constructor directly? I guess by using the parameterized constructors, one can invoke other constructors easily.

    3. Since it is static, we can access it by using the enum Name. Since it is final, we can’t create child enums.

      enum in java is implemented as a class. The static and final keywords have their meanings.

      An enum cannot explicitly inherit a class not can it create child enums.

    4. enum can implement many interfaces

      Have to learn about Interfaces.

    5. All enums implicitly extend java.lang.Enum class. As a class can only extend one parent in Java, so an enum cannot extend anything else.

      In Java, a class can extend only one parent class. Also, an enum implicitly extends the java.lang.Enum class. Therefore, an enum cannot extend anything else.

    6. In Java, we can also add variables, methods and constructors to it

      java enums allow one to add variables, methods and constructors. Java enums are apparently more powerful than C++ enums

    7. enum type can be passed as an argument to switch statement.

      An enum object can be created and the object can be passed as an argument.

  2. Jun 2021
    1. It is a compile-time error if an enum declaration has the modifier abstract orfinal.

      enum is implicitly static and final, no reason to have modifiers final and abstract.

  3. Mar 2018