Image Chapter 12 Self Test

1. Enumeration constants are said to be self-typed. What does this mean?

2. What class do all enumerations automatically inherit?

3. Given the following enumeration, write a program that uses values( ) to show a list of the constants and their ordinal values.

Image

4. The traffic light simulation developed in Try This 12-1 can be improved with a few simple changes that take advantage of an enumeration’s class features. In the version shown, the duration of each color was controlled by the TrafficLightSimulator class by hard-coding ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.