What will be the result of compiling and running the following code?.
public enum Main { RED("Stop"), YELLOW("Caution"), GREEN("Go"); private String action; Main(String action) {/*from w ww . ja v a 2s.co m*/ this.action = action; } public static void main(String[] args) { Main green = new Main("Go"); System.out.println(GREEN.equals(green)); } }
Select the one correct answer.
equals()
method.(c)
All enum types override the equals()
method from the Object class.
The equals()
method of an enum type compares its constants for equality according to reference equality (same as with the == operator).
This equals()
method is final.