What are some of the advantages of creating an enumeration type?
What will be an ideal response?
Creating an enumeration type provides you with several advantages:
* If you did not create an enumerated type for month values, you could use another type-for example, ints or Strings. The problem is that any value could be assigned to an int or String variable, but only the 12 allowed values can be assigned to a Month.
* If you did not create an enumerated type for month values, you could create another type to represent months, but invalid behavior could be applied to the values. For example, you could add or subtract two months, which is not logical. Programmers say using enums makes the values type-safe. Type-safe describes a data type for which only appropriate behaviors are allowed.
* The enum constants provide a form of self-documentation. Someone reading your program might misinterpret what 9 means as a month value, but there is less confusion when you use the identifier OCT.
* As with other classes, you can also add methods and other fields to an enum type.
You might also like to view...
What Windows Vista/7 tool is used when the computer has problems booting? (Select the best answer.)
A) System Restore B) Memory Diagnostic Tool C) Complete PC Repair D) Startup Repair
A 300-dpi printer is one that is capable of printing ____________________ dots per square inch.
Fill in the blank(s) with the appropriate word(s).
A customer states that since the new firewall has been installed, the customer has not been able to send email. Which of the following ports on the firewall should be checked?
A. 21 B. 25 C. 110 D. 443
?The _______________ format is an image format produced by the Nuance PaperPort scanning program.
Fill in the blank(s) with the appropriate word(s).