101k views
5 votes
Regarding enumerations, the ____ method returns an array of the enumerated constants.

a.
values

b.
valueOf

c.
toArray

d.
ordinal

User Boucekv
by
5.7k points

1 Answer

6 votes

Answer:

a. values

Step-by-step explanation:

The values() method returns an array of all values of an enumeration. This method is defined automatically by the java compiler for the enum data type.

For example:

enum Traffic_Signal {RED,YELLOW,GREEN};

for(Traffic_Signal t : Traffic_Signal.values()){

System.out.println(t);

}

This code segment will print out all the valid values in the Traffic_Signal enumeration.

User Filipe Amaral
by
6.5k points