Which four are true about enums?

Which four are true about enums?

Which four are true about enums?

A.
All enums implicitly implement Comparable.

B.
An enum can subclass another enum.

C.
An enum can implement an interface.

D.
An enum can declare a private constructor.

E.
An enum is typesafe.

F.
An enum cannot have public methods or fields.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


leo yu

leo yu

public interface Operator{
int apply(int a, int b);
}

public enum SimpleOperator implements Operator{
PLUS(“plus”){
public int apply(int a, int b){return a+b;}
},
MINUS(“minus”){
public int apply(int a, int b){return a-b;}
};

private String name;
SimpleOperator(String name){
this.name = name;
}

}

public class Tester{
public static void main(String[] args){
System.out.println(SimpleOperator.PLUS.apply(2,3));
}
}