1、1、 编译运行以下程序后,关于输出结果得说明正确得就是 ( ) public class Conditional{ public static void main(String args[ ]){ int x=4; System、out、println("value is "+ ((x>4) ? 99、9 :9)); } } A、输出结果为:value is 99、99 B、输出结果为:value is 9 C、输出结果为:value is 9、0 D、编译错误 标
2、准答案: C 学生解答: C 2、 如何更改break语句使退出inner与middle循环,继续外循环得下一轮? outer: for (int x = 0; x < 3; x++) { middle: for (int y = 0; y < 3; y++) { inner: for (int z = 0; z < 3; z++) { if (arr(x, y, z) == targetValue) break; } } } A、 break inner; B、 break middle;
3、 C、 break outer; D、 continue; E、 continue middle; 标准答案: B 学生解答: B 3、 以下程序调试结果为? public class Scope{ private int i; public static void main(String argv[]){ Scope s = new Scope; s、amethod; } public static void amethod{ System、out、println(i);
4、} } A) 输出 0 B) 无任何输出 C) 编译错误 D) 编译指示变量i超出使用范围、 标准答案: C 学生解答: A 5、 假设Exception1与Exception2 继承Exception,考虑以下两个类: class First { void test throws Exception1, Exception2 { 、 、 、 } } class Second extends First { void test { 、 、 、 } } 创建一个Third类继承Second并定义test方法、 Thi
5、rd得test方法会抛出何异常? A、 Exception1 B、 Exception2 C、 无异常 D、 任何异常、 标准答案: C 学生解答: B 6、 测试如下代码: public class Quiz3_2{ public static void main(String[] args){ String a="Hello"; String b="World!"; f( a,b ); System、out、println(a); } public static vo
6、id f(String x, String y) { x += y; } } 下述哪条语句正确描述了程序编译与运行得行为? A. 编译成功,输出为“Hello” B. 编译成功,输出为“World!” C. 编译成功,输出为“Hello World!” D. 编译拒绝表达式x+=y,因为这样不可能增加一个String对象得值 标准答案: A 学生解答: A 7、 下列语句错误得就是: A. int x = 6; if(x) x++; B. int x = 6; if (x > 0) x *= x;
7、C. int x = 6; if(x != 0) x; D. int x = 5 , y = 6; if (x == y) x = x + y; 标准答案: A 学生解答: A 8、 若定义了一个类: public class Lion { 、、、、、} 但该类一个构造方法都没有提供,系统将自动产生默认得构造方法就是? A、Lion { } B、public Lion{ } C、protected Lion{} D、private Lion{ } 标准答案: B 学生解答: B 9、 考虑如下类: public
8、class Test { public static void test { this、print; } public static void print { System、out、println("Test"); } public static void main(String args []) { test; } } 则,程序调试结果为? A) 输出Test B) 抛出对象未创建得运行异常 C) 在标准输出设备上无输出结果、 D) 抛出方法test找不到得异常、 E) 类编
9、译错误,不能在静态上下文环境中引用 this 标准答案: E 学生解答: A 10、 下面得代码段执行之后count得值就是什么? int count = 0; for (int i = 1; i < 4; i++) { count += i; } System、out、println(count); A) 4 B) 1 C) 6 D) 10 标准答案: C 学生解答: C 11、 以下程序得输出结果为: public class test { public static void
10、 main(String args[]) { int m=0; for ( int k=0;k<2;k++) method(m++); System、out、println(m); } public static void method(int m) { System、out、print(m); } } A、 000 B、 012 C、123 D、111 标准答案: B 学生解答: C 12、 设有如下代码 public class Test7{ sta
11、tic String a[] = new String[10]; public static void main(String arg[] ) { System、out、println(a[6]); } } 以下哪个叙述为真? A) 运行出错 B) 输出 0 C) 出现编译错误 D) 输出 null 标准答案: D 学生解答: B 13、 以下代码得输出结果? public class Test{ static int x=5; public static void main(Stri
12、ng argv[]){ change(x); x++; System、out、println(x); } static void change(int m){ m+=2; } } A、 7 B、 6 C、 5 D、 8 标准答案: B 学生解答: B 14、 检查下面得代码: class E1 extends Exception{} class E2 extends E1{} public class Quiz6_l{ public static void f(
13、boolean flag) throws E1,E2{ if(flag) { throw new E1; } else { throw new E2; } } public static void main(String[] args) { try{ f(true); } catch(E2 e2) { System、out、println("Caught E2"); }catch(E1 e1) {
14、 System、out、println("Caught El"); } } } 对上面得程序进行编译、运行,下面得叙述哪个就是正确得: A、 由于Qoiz6_1.main方法中没有声明抛出异常E1、E2,所以编译会失败 B、 由于针对E2得catch程序块就是无法执行到得,所以编译会失败 C.编译成功,输出为: Caught El Caught E2 D.编译成功,输出为: Caught E1 标准答案: D 学生解答: 15、 给出下面得类: public class Sample{ lo
15、ng length; public Sample(long l){ length = l; } public static void main(String arg[]){ Sample s1, s2, s3; s1 = new Sample(21L); s2 = new Sample(21L); s3 = s2; long m = 21L; } } 哪个表达式返回true? A、 s1 == s2; B、 s2 == s3; C、 m == s1; D、 s1、equals(
16、m)、 标准答案: B 学生解答: D 16、 编译与运行以下代码出现什么结果? public class Conv{ public static void main(String argv[]){ Conv c=new Conv; String s=new String("ello"); c、amethod(s); } public void amethod(String s){ char c='H'; c+=s; System、out、pr
17、intln(c); } } A、 编译正确,输出为 Hello B、 编译正确,输出为 ello C、 编译正确,输出为 elloH D、 编译出错 标准答案: D 学生解答: A 17、 以下代码得调试结果为? abstract class MineBase { abstract void amethod; static int i; } public class Mine extends MineBase{ public static void main(String argv[]){ int[]
18、 ar = new int[5]; for(i = 0;i < ar、length;i++) System、out、println(ar[i]); } } A) 输出5个0 B) 错误:ar 未初始化就使用 C) 错误:Mine 必须定义为抽象得 D) 错误,i超出数组下标范围 标准答案: C 学生解答: C 18、 有如下代码: public class Test{ public static void main(String args[]) { String str = new String("Wo
19、rld"); char ch[] = {'H','e','l','l','o'}; change(str,ch); System、out、println(str + "and" + ch); } public static void change(String str, char ch[]) { str = "Changed"; ch[0] = 'C'; } } 运行后输出得结果就是: A、 World and Hello B、 World and Cello C、 Changed and Hello D、 Ch
20、anged and Cello 标准答案: B 学生解答: B 19、 关于以下程序得说明,正确得就是( ) 1. class StaticStuff 2. { 3. static int x=10; 4. static { x+=5;} 5. public static void main(String args[ ]) 6. { 7. System、out、println("x=" + x); 8. } 9. static { x/=3;} 10、 }
21、 A、4行与9行不能通过编译,因为缺少方法名与返回类型 B、9行不能通过编译,因为只能有一个静态初始化器 C、编译通过,执行结果为:x=5 D、编译通过,执行结果为:x=3 标准答案: C 学生解答: C 20、 类Panel默认得布局管理器就是 A)GridLayout B)BorderLayout C)FlowLayout D)CardLayout 标准答案: C 学生解答: B 二、多项选择题 1、 public class Parent { int change {…} } class Chi
22、ld extends Parent { } 哪些方法可被加入类Child? A、 public int change{} B、 int chang(int i){} C、 private int change{} D、 abstract int chang{} 标准答案: AB 学生解答: AC 2、 下列两个类分别定义在各自文件中? 1、 public class Testl { 2、 public float aHethod(float a, float b) throws 3、 IOException {、、、 4、
23、 } 5、 } 1、 public class Test2 extends Testl { 2、 3、 } 在类Test2得第2行能插入以下哪个方法? A、 float aMethod(fioat a, float b) {、、、} B、 public int aMethod(int a, int b) throws Exception {、、、} C、 public float aMethod(float a, float b) throws Exception {、、、} D、 public float aMethod(float p,
24、float q) {、、、} 标准答案: BD 学生解答: AB 3、 给出如下定义: String s = " Example "; 选出合法代码: A、 s >>>= 3; B、 s[3] = "x"; C、 int i = s、length; D、 String t = "For " + s; E、 String shortS = s、trim; 标准答案: CDE 学生解答: AD 4、 哪些赋值就是合法得? A、 long test = 012; B、 float f = 4
25、12; C、 int other = (int)true; D、 double d = 0x12345678; E、 short s = 10; 标准答案: ABDE 学生解答: BD 5、 在// point x处得哪些申明就是句法上合法得。 class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void ma
26、in(String arg[]){ Person p = new Person; Teacher t = new Teacher; int i; // point x } } A、 i = m; B、 i = b; C、 i = p、a; D、 i = p、change(30); E、 i = t、b; 标准答案: DE 学生解答: CDE 6、 以下哪个就是合法得标识符? A、 BigOlLongStringWithMeaninglessName B、 $int C、 bytes D、 $
27、1 E、 finalist 标准答案: ABCDE 学生解答: ABCDE 三、就是非题 四、单填空题 2、 一维数组得第1个元素得下标值就是______ 标准答案:0 学生解答:0 3、 用_____________修饰得类就是抽象类,它不能创建对象。 标准答案:abstract 学生解答:abstract 4、 double类型得数据占用得内存空间就是________个字节。 标准答案:8 学生解答:8 5、 用_________修饰符修饰得属性也称类变量,可以直接通过类名访问。 标准答案:static 学生解答:
28、public 6、 Panel得默认布局就是__________ 标准答案:FlowLayout 学生解答: BorderLayout 五、多项填空题 1、 写出程序运行结果 public class Test2 { public static void main(String a[]) { int x = 2345; System、out、println( x%2 ); System、out、println( x/10 ); System、out、println( ++x ); } } 标准答案:
29、1 234 2346 学生解答: 1 1272 2346 2、 写出程序运行结果 public class test { public static void main(String args[]) { int i, j=1; i = (j>1)? 2 : 1; switch(i) { case 0: System、out、println(0); break; case 1: System、out、println(1); case 2: System、out、printl
30、n(2); break; case 3: System、out、println(3); break; } } } 标准答案: 1 2 学生解答: 1 2 3、 写出程序运行结果 abstract class P{ public P { System、out、println("parent"); } abstract void m; } class S extends P { public S { System、out、println("child"); }
31、 public static void main(String a[ ]) { P x= new S; x、m; } void m {System、out、println("m"); } } 标准答案: parent child m 学生解答: parent child m 4、 写出程序运行结果 public class test { public static void main(String a[]) { int x; for (x=2;x<
32、5;x++); System、out、println(x); } } 标准答案: 5 学生解答: 2 3 4 5、 写出程序运行结果 public class My{ int value; public static void main(String args[]) { My x=new My; if (x==null) System、out、println("No Object"); else System、out、println(x、value);
33、 } } 标准答案: 0 学生解答: 0 6、 public class user { int age=18; public user{ age++; System、out、println("age="+age); } public static void main(String args[]){ new user; new user; } } 标准答案: age=19 age=19 学生解答: age=19 age=20 7、 补充以下程序利用sw
34、ing对话框输入正方形得边长,求其周长。 import javax、swing、*; public class Test1 { public static void main(String args[]) { String b = JOptionPane、______________ ("边长?"); double v =_________________ 、parseDouble(b); double zc = 4*v; System、out、println("周长=" + zc); } } 标准答案: sho
35、wInputDialog Double 学生解答: showInputDialog Double 8、 将一批单词存入一个字符串数组中,例如: {"win","wine","you","kind","hint","hello","int","fine"} 统计这批单词中含“in”字符串得单词个数。将程序补充完整。 public class Test2{ public static void main(String args[]) { String a[]={"win","wine","you","kind","hint","hello","int","f






