[Attention] Enum is thoroughly tested in real exam
Posted: Sat Mar 15, 2014 2:58 am
I just did a real 1Z0-804 exam today and did not think I should have paid so much attention to this part.
1) It is a compile-time error if a constructor declaration of an enum type is public or protected. Instead, the constructor should have a private modifier or just ignore it. If an enum type has no constructor declarations, then a private constructor that takes no parameters (to match the implicit empty argument list) is automatically provided.
2) Enums are implicitly declared public, static, and final, which means you cannot extend them. But enums can implement interfaces.
3) Enumeration constants cannot be cloned. An attempt to do so will result in a CloneNotSupportedException.
4) Go through Enum's methods such as ordinal(), which returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).
5) Enum can have nested classes.
1) It is a compile-time error if a constructor declaration of an enum type is public or protected. Instead, the constructor should have a private modifier or just ignore it. If an enum type has no constructor declarations, then a private constructor that takes no parameters (to match the implicit empty argument list) is automatically provided.
2) Enums are implicitly declared public, static, and final, which means you cannot extend them. But enums can implement interfaces.
3) Enumeration constants cannot be cloned. An attempt to do so will result in a CloneNotSupportedException.
4) Go through Enum's methods such as ordinal(), which returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).
5) Enum can have nested classes.