An enumeration is a feature added to J2SE 5. It is very similar to a class, except that it cannot be instantiated. It is declared using the keyword enum. An enumeration can have constructors, methods, and instance variables in the same way as a class. Identifiers of an enum are referred to as enum constants. These constants cannot have any type other than the enum-type itself. An enum constructor can never be invoked directly. They are always called automatically on initialization. An enum can be declared inside, as well as outside a class. When declared outside a class, it should be declared either public or default. It cannot be private, protected, static, abstract, or final. A semicolon in the enum declaration is optional and may be put at the end of enum declaration.
An enum is declared as follows:
- Download practice question and study guide for master-ciw-enterprise-developer for exam.
- Pass SCBCD in first attampt.
- Click here to download scdjws test study guide and practice question.
- Click here to get free scja SCJA exam practice questions.
- Click here to get free scjp SCJP exam practice questions.
- Click here to download scjp-5-0 test study guide and practice question.
- Click here to download scmad test study guide and practice question.
- Download free practice test for SUN SCWCD exam.
- Download free practice test for SUN SCJA exam.
- Become SUN Java 5.0 certified.
- Get certified in first attempt download CX310-056 - SCJP 5.0 Java Upgrade simulation.
- Become SUN SCJP 6.0 certified.
- Become SUN SCJP Upgrade certified.