单项选择题
定义枚举如下:
public enum Direction{
EAST,SOUTH,WEST,NORTH
}
下列正确使用该枚举类型的语句是哪项?()
A.Direction Direction=EAST;
B.Direction direction=Direction.WEST;
C.int a- Direction.NORTH;
D.Direction direction=2;
相关考题
-
单项选择题
现有: class TestFoo f int x; String y; int getX() { return x; } String getY() {return y; } void setX (int x) { int Z=7: this.x=x; } 可以添加多少个修饰符来封装此类?()
A.5
B.4
C.3
D.2 -
单项选择题
现有: class Banana2 f static int X=2; public static void main (String [] args) { int X=2; Banana2 b=new Banana2(); b.go(x); } static {x+=x; } void go (int x) { ++x; System. out.println (x); } 结果为:()
A.7
B.5
C.3
D.2 -
单项选择题
我们定义一个Account类来描述银行账户,银行账户有账户名、金额等属性特征,同时有存款、取款等行为特征,下述代码适合描述的是哪项?()
A.class Accountf String name;//账户 S tring amount; //金额 Account (String name)( ) void deposit (double mount){ //存款 ) void withdraw (double mount){ //取款 } )
B.class Accountf String name;//账户d ouole amount; //金额 Account(double amount){ } void deposit (double mount){ //存款 ) void withdraw (double mount){ //取款 ) )
C.class Accountf String name;//账户 double amount; //金额 Account (String name){} void deposit (double mount){//存款 ) void withdraw (double mount){ //取款 ) )
D.class Accountf String name;//账户 double amount;//金额 Account (String name){} void deposit(){//存款 ) void withdraw(){//取款 ) )
