18.下列程序段执行后t5的结果是多少? int t1 = 9, t2 = 11, t3=8; int t4,t5;
t4 = t1 > t2 ? t1 : t2+ t1; t5 = t4 > t3 ? t4 : t3; A.8 B.20 C.11 D.9
19.下列哪个表达式的值是x和y的最大值? A. x>y?y:x B.x
20.有一声明语句为boolean t; 下面赋值语句中t的值为false的是哪个? A.t=5>3; B.t=!false; C.t=(true|false); D.t=(2==3)?true:false;
21.执行下列程序段后,m,x,y 的值分别是多少? int x=2,y=4; boolean m; m=++x>y--; A.true, 2,4 B.true, 3, 3 C.false, 2,4 D.false, 3, 3
22.给出下面的代码:
if (x>0) { System.out.println(\
else if (x>-3) { System.out.println(\ else { System.out.println(\x 的取值在什么范围内时将打印字符串\。 A.x > 0 B.x > -3 C.x <= -3 D.x <= 0 & x > -3
23.下列关于for循环和while循环的说法中哪个是正确的? A.while循环能实现的操作,for循环也都能实现
B.while循环判断条件一般是程序结果,for循环判断条件一般是非程序结果
C.两种循环任何时候都可替换 D.两种循环结构中都必须有循环体 24.下列语句序列执行后,x 的值是多少? int a=3, b=4, x=5; if ( ++a
25.给出下面的代码: public class Test {
void printValue(int m){
do { System.out.println(\ }while( --m > 8 ) }
public static void main(String arg[]) { int i=10;
Test t= new Test();
t.printValue(i); } }
输出将是什么? A.The value is 10 The value is 8 B.The value is 9 The value is 8 C.The value is 10 The value is 9 D.The value is 11 The value is 10
26.下面代码执行后,正确的输出结果是哪一个? public class Excmple{
public static void main(String args[] ){ int i=0; do{
System.out.println(\ } while(--i>0);
System.out.println(\ } }
A.Doing it for i is 0 B.Doing it for i is 1 C.Doing it for i is 2 D.Doing it for i is 3
27.以下程序运行时,哪一行会产生编译错误? 1) public void modify() { 2) int i, j, k; 3) i = 100;
4) while ( i > 0 ) { 5) j = i * 2;
6) System.out.println (\7) k = k + 1; 8) i--;
9) } 10) } A.line 5 B.line 6 C.line 7 D.line 8
28.执行以下程序,哪一行将出错? 1) String str = null;
2) if ((str != null) && (str.length() > 10)) { 3) System.out.println(\ 4) }
5) else if ((str != null) & (str.length() < 5)) { 6) System.out.println(\ 7) }
8) else { System.out.println(\ A.第1行 B.第2行 C.第5行 D.第8行
多选题:(共6道试题,每题2分)
1.下面有关Java代码安全性的叙述哪些是正确的? A.字节码校验器加载查询执行需要的所有类。 B.运行时解释器执行代码。
C.在运行时,字节码被加载,验证然后在解释器里面运行。
D.类加载器通过分离本机文件系统的类和从网络导入的类增加安全性。 2.以下描述中哪些不是Java关键字? A.TRUE B.sizeof
C.const D.super
3.以下哪些是字节码校验器进行校验的内容? A.类是否符合JVM规范的类文件格式 B.有没有违反访问限制
C.所有操作代码的参数类型是否正确 D.有没有非法的数据类型转换 E.代码有没有造成堆栈的上溢或者下溢 4.下面关于变量的描述哪些是正确的? A.实例变量是类的成员变量。 B.实例变量用关键字static声明。
C.在方法中定义的局部变量在该方法被执行时创建。 D.局部变量在使用前必须被初始化。 5.下面有关变量及其作用域的描述哪些是正确的?
A.在方法里面定义的局部变量在方法退出的时候被撤销。 B.局部变量也叫自动变量。
C.在方法外面定义的变量(即实例变量)在对象被构造时创建。 D.在方法中定义的参变量也是方法的局部变量。
6.给出下面的代码片断: 1) switch(m)
2) { case 0: System.out.println(\
3) case 1: System.out.println(\ 4) case 2:
5) default: System.out.println(\ 6) }
m为何值时输出值将会为“default”。 A.0