1. 下面哪个是合法的标识符?( )
A.2persons B. TwoUsers
C. *point D.this
2. 如果定义有double x;float y;int m,则表达式x*y-m的类型为( ):
A、double B、float C、int D、short
3. 如果定义有short s;byte b;char c,则表达式s*b+c的类型为( ):
A、char B、short C、int D、byte
4. 已知int i= 21474837; ++i; 则i的值等于多少( )
A -21474838 B 21474837 C 21474838
5. 已知byte i= 127; ++i; 则i的值等于多少( )
A -128 B 127 C 128
6. 已知byte i= 127; i=i+1;这两行语句能否编译成功?( )
7. 执行以下程序段
int a=5,b; b=++a*3后b的值为:( )
A、17 B、18 C、16 D、15
8. 如果x=3,y=5,则表达式x|y的值为:( )
A、15 B、8 C、1 D、7
9. 如果int a=3,b=2,则执行a*=b+8后a的值为:( )
A、20 B、14 C、30 D、16
10. 若所用变量都已正确定义,以下选项中,非法的表达式是:( )
A、a!=4||b==1 B、'a'%3 C、'a'=1/2 D、'A'+32
11.下列( )不属于Java语言流程控制结构?
(A)分支语句 (B)跳转语句 (C)循环语句 (D)赋值语句
12.假设a是int类型的变量,并初始化为1,则下列( )是合法的条件语句?
(A)if(a){} (B)if(a<<=3){} (C)if(a=2){} (D)if(true){}
13.下列说法中,不正确的一个是( )。
(A)switch语句的功能可以由if…else if语句来实现
(B)若用于比较的数据类型为double型,则不可以用switch语句来实现
(C)if …else if语句的执行效率总是比switch语句高
(D)case子句中可以有多个语句,并且不需要大括号{}括起来
14.设a、b为long型变量,x、y为float型变量,ch为char类型变量且它们均已被赋值,则下列语句中正确的是( )。
(A)switch(x+y) {}
(B)switch(ch+1) {}
(C)switch( ch) {}
(D)switch(a+b) {}
15.下列循环体执行的次数是( )。
int y=2, x=4;
while(--x != x/y){ }
(A)1 (B)2 (C)3 (D)4
16.下列循环体执行的次数是( )。
int x=10, y=30;
do{ y -= x; x++; }while(x++ 17.已知如下代码: switch(m){ case 0: System.out.println("Condition 0"); case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2"); case 3: System.out.println("Condition 3");break; default:System.out.println("Other Condition"); } 当m的值为( )时,只输出“Condition 3” (A)2 (B)3 (C)0、1、2 (D)0、1、2、3 二、写出下列程序的运行结果 1. public class X3_3_1 { public static void main(String[] args) { for(int i=0; i<10; i++){ if(i==5) break; System.out.print(i); } } } 【运行结果】 2. public class X3_3_2 { public static void main(String[] args) { int i=5, j=2; while(j } } 【运行结果】 3. public class X3_3_4 { public static void main(String[] args) { int j=0; for(int i=3; i>0; i--){ j += i; int x = 2; while(x System.out.print(x); } } } } 【运行结果】 4. public class X3_3_6 { public static void main(String[] args) { int a=0, b=1; do{ if(b%2==0) a += b; b++; }while(b <= 100); System.out.print(a); } } 【运行结果】 5. public class X3_3_8 { public static void main(String[] args) { char ch='7'; int r=10; switch(ch+1){ case '7': r += 7; case '8': r += 8; case '9': r += 9; default: } System.out.print(r); } } 【运行结果】