【JAVA】——一阶段练习题

1. 下列哪个选项是合法的标识符(2分)(B)

A.123 B._name

C.class D.1first

2. 编译运行以下程序后,关于输出结果的说明正确的是(C)

public class Conditional{

public static void main(String args[ ]){

    int x=4;

System.out.println(“value is “+ ((x>4) ? 99.9 :9));

    }

}

(2分)

A.输出结果为:value is 99.99        

B.输出结果为:value is 9

C.输出结果为:value is 9.0

D.编译错误

3. 下面的方法,当输入为2的时候result是多少? (B)

int result = 0;  
switch (i) {  
    case 1:  
result = result + i;  
    case 2:  
result = result + i * 2;  
    case 3:  
result = result + i * 3;  
}

(2分)

A.0                 B.2

C.4                D.10

4. 下列语句的输出结果是()

public class Test {

 public static void main(String[] args) {

  int x = 1, y = 1, z = 1;

  if (x-- == 1 && y++ == z && z++ == 1) {

   System.out.println("x=" + x + ",y=" + y + ",z=" + z);

  }

}}(2分)

A

x=0,y=2,z=1

B

x=1,y=2,z=1

C

x=0,y=2,z=2

D

没有输出

5. 

以下程序调试结果为:

class Base{

Base(){

int i = 100;

System.out.print (i);

}

}

public class Pri extends Base{

static int i = 200;

public static void main(String argv[]){

Pri p = new Pri();

System.out.print(i);

}

}(2分)

A

编译错误

B

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值