Given:

public enum USCurrency {
    PENNY(1),
    NICKLE(5),
    DIME(10),
    QUARTER(25);
    private int value;

    public USCurrency(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }
}
public class Coin {

    public static void main(String[] args) {
        USCurrency usCoin = new USCurrency.DIME;
        System.out.println(usCoin.getValue());
    }
}

Which two modifications enable the given code to compile?

A. Nest the USCurrency enumeration declaration within the Coin class.
B. Make the USCurrency enumeration constructor private.
C. Remove the new keyword from the instantion of usCoin.
D. Make the getter method of value as a static method.
E. Add the final keyword in the declaration of value.

题解

enum 构造器的可见度只能使用 default 或是 private。使用 enum 预先枚举好的常数不需要使用 new 操作符。因此这题答案是选项 B 和选项 C。