What will be the result of compiling and running the following code?.
import java.util.Arrays; public enum Main { ONE(1) { public String toString() { return "LOW"; } }, // (1) TWO(2),/* w w w .jav a2s . com*/ THREE(3) { public String toString() { return "NORMAL"; } }, // (2) FOUR(4), FIVE(5) { public String toString() { return "HIGH"; } }; // (3) private int v; Main(int v) { this.v = v; } public static void main(String[] args) { System.out.println(Arrays.toString(Main.values())); } }
Select the one correct answer.
(c)
An enum type can be run as a standalone application.
(1), (2), and (3) define constant-specific class bodies that override the toString()
method.
For constants that do not override the toString()
method, the name of the constant is returned.