Java 程序设计习题及历年考试题单项选择题(80)1. 接口中的成员变量被隐含地声明为(A)public static final(B)public final(C)public static(D)public abstract2. 处理按钮点击事件的类需要实现哪个接口(A)FocusListener(B)ActionListener(C)WindowListener(D)ItemListener3. 已知:class A {public final void m() {System.out.println(“A.m”);}}public class B extends A {public void m() {System.out.println(“B.m”);super.m();}public static void main(String [] args) {new B().m();}}那么结果为?(A)A.m(B)B.m(C)B.mA.m(D)编译错误4. 抛出异常,使用关键字(A)try(B)throw(C)finally(D)catch5. 已知:class Base {public Base(String s) {System.out.print(“B”);}}public class Derived extends Base {public Derived (String s) {System.out.print(“D”);}public static void main(String [] args) {new Derived (“C”);}}那么结果为?(A)BD(B)DB(C)C(D)编译错误6. Java 中char类型的数据长度为(A)8位(B)16位(C)32位(D)64位7. Java 编译输出文件的后缀是(A).exe(B).java(C).class(D).obj8. 已知:class C {public static void main(String[] args) {boolean a = true;boolean b = false;boolean c = true;if((a & b) | (b & c) & c)System.out.print(“A”);If((a = false) | (a & c) ) | (a | b))S ystem.out.print(“B”);}}(A)A(B)B(C)AB(D)编译错误9. 下面哪个表达式是错误的(A)int i = 100;(B)float f = 100.0;(C)Object o = “Hello world”;(D)char c = …\u1234‟;10. 引用类型的数据字段的缺省值为(A)0.0(B)0(C)null(D)false11. 下面哪个表达式可以获取字符串s 的最后一个字符(A)s.length()(B)s[s.length() - 1](C)s.charAt(s.length() - 1)(D)charAt(s, length(s))12. 数据字段的作用域是(A)所在的语句块(B)所在的类(C)所在的方法(D)所在的构造函数13. 如果类中的成员只能被子类或同一包中的类访问,那么声明该成员时应使用下面哪个修饰符(A)private(B)package(C)protected(D)public14. import语句的作用是(A)导入包中成员(B)创建包(C)既可导入包成员,也可创建包(D)访问控制15. 已知:class C {public static void main(String[] args) {int a = 1;int b = 2;System.out.print( “7” + 5 + 4);System.out.print(m() + a + 3);System.out.println(a + b + m());}public static String m() {return “6”;}}(A)79613126(B)79614336(C)75461336(D)75461312616. 接口中的成员方法被隐含地声明为(A)public static final(B)protected abstact(C)private(D)public abstract17. 关于包的描述错误的是(A)包可以将相关的类和接口组织在一起,便于识别和管理(B)包中的类可以访问同一包的其它类的私有成员(C)不同包中的相同命名,不会产生冲突(D)用public 修饰的顶级类和接口对包外代码可见18. 下面代码的输出是class C {public static void main(String[] args) {int x = 1;System.out.print((x > 1) & (x++ > 1));System.out.print( ““);System.out.print((x > 1) && (x++ > 1));}}(A)false true(B)true false(C)false false(D)true true19. float[] f = new float[10],则f[0]的值为(A)0.0(B)0.0f(C)null(D)false20. 下面哪个类不能直接读取磁盘文件(A)FileReader(B)RandomAccessFile(C)FilterReader(D)FileInputStream21. 如果类中的成员只能被同一包中的类访问,那么声明该成员时应使用下面哪个修饰符(A)protected(B)package(C)public(D)不使用访问修饰符22. 表达式new StringTokenizer( “Welcome to java”).countTokens()的值是(A)1(B)3(C)13(D)1523. JPanel 的缺省布局管理器是(A)BorderLayout(B)FlowLayout(C)GridLayout(D)SpringLayout24. JFrame 的缺省布局管理器是(A)BorderLayout(B)FlowLayout(C)GridLayout(D)BoxLayout25. 已知:public class C {public int m(int x) {int r = 1;r += x;if ((x > 5) && (x < 10)) {r += 2 * x;} else (x <= 4) {r += 3 * x;} else {r += 4 * x;}r += 5 * x;return r;}public static void main(String [] args) {C o = new C();System.out.println(“m(11) = “ + o.m(11));}}(A)m(11) = 45(B)m(11) = 56(C)m(11) = 89(D)m(11) = 11126. 已知:目录结构dira|---A.class|---dirb|---B.class和源代码import dira.*;class C {A a;B b;}那么要使源代码通过编译,需要在源代码中添加(A)package dira;(B)package dirb;(C)package dira.dirb;(D)package dirb.dira;27. 如果java.awt.Container c 的布局为BorderLayout,则c.add(new Jbutton())的默认位置参数是(A)BorderLayout.EAST(B)BorderLayout.WEST(C)BorderLayout.CENTER(D)编译错误28. 已知:class C {public static void main(String[] args) {String s = “welcome to java”;System.out.println(s.substring(11));}}的输出为(A)java(B)welcome to(C)ome to java(D)welcome to java29. 已知:class C {int i = 1;int j = 2;public void swap() {int temp = i;i = j;j = temp;}public static void main(String[] args) {C c = new C();c.swap();System.out.println(c.i + “,” + c.j);}}的输出为(A)1,1(B)1,2(C)2,1(D)2,230. 已知:class B {int i;B(int i) {this.i = i;}}class C extends B {public static void main(String[] args) {C c = new C(1);System.out.println(c.i);}}的输出为(A)0(B)1(C)编译错误(D)运行时错误31. 已知:class C {int x;String y;public C() {this( “1”);System.out.print(“one “);}public C(String y) {this(1, “2”);System.out.print(“two “);}public C(int x, String y) {this.x = x;this.y = y;System.out.print(“three “);}public static void main(String[] args) {C c = new C();System.out.println(c.x + ““ + c.y);}}则输出为(A)1 2 one two three(B)1 2 three two one(C)one two three 1 2(D)three two one 1 232. 已知:class C {public static void main(String[] args) {int x = 5;C c = new C();c.m(x);System.out.print(x);}public void m(int x) {System.out.print(x++);}}则输出为(A)55(B)56(C)65(D)6633. 已知:interface I { }class A implements I { }class B extends A { }class C extends B {public static void main(String[] args) {B b = new B();_____________}}在横线处添加哪条语句运行时会产生异常(A)A a = b;(B)I i = b;(C)C c = (C)b;(D)B d = (B)(A)b;34. 已知:class C {public static void main(String[] args) {String s = “null”;if(s == null)System.out.print( “a”);else if(s.length() == 0)System.out.print( “b”);elseSystem.out.print( “c”);}}的输出为(A)a(B)b(C)c(D)null35. 已知:class C {public static void main(String[] args) {BufferedReader br = null;try {br = new BufferedReader(new FileReader( “in.txt”));String temp = null;while((temp = br.________) != null) {System.out.println(temp);}} catch(Exception e) {} finally {if(br != null) {br.close();}}}}要想打印出in.txt 的全部内容,需要在横线处填写(A)read()(B)next()(C)readLine()(D)nextLine()36. 已知:class Student {String code, name;int age;public boolean equals(Object o) {if(!o instance of Student) {return false;}Student s = (Student)o;return o.code == code && o.age == age;}public int hashCode() {_________________}}横线处应填写(A)return code.hashCode();(B)return code.hashCode() + age * 11;(C)return code.hashCode() + name.hashCode() + age * 11;(D)return super.hashCode();37. 已知:class C {public static void main(String[] args) {parse( “number”);}public static void parse(String s) {try {int i = Integer.parseInt(s);} catch(NumberFormatException e) {i = 0;} finally {System.out.println(i);}}}则输出为(A)0(B)编译错误(C)运行时抛出ParseException(D)运行时抛出NumberFormatException38. 已知:public interface I {void m();}下面哪个定义是合法的(A)public interface J extends I {}(B)public interface J implements I {}(C)public interface J inherits I {}(D)public interface J instanceof I {}39. 已知:abstract class Shape {private int x, y;void setLocation(int x, int y) {this.x = x;this.y = y;}abstract void draw();}class Circle extends Shape {void draw() {}}class Test {public static void main(String[] args) {_________________}}下面哪段代码在横线处是合法的(A)Shape s = new Shape();s.setLocation(1,1);s.draw();(B)Circle c = new Shape();s.setLocation(1,1);s.draw();(C)Shape s = new Circle()s.setLocation(1,1);s.draw();(D)Shape s = new Circle()s.Shape.setLocation(1,1);s.Shape.draw();40. Java 的屏幕坐标系的(0,0)在屏幕的(A)中心(B)左上角(C)左下角(D)右下角41. 已知:class C {public static void main(String[] args) {int i = 10;System.out.println(i < 8 ? 1.0 : 1);}}(A)1(B)1.0(C)8(D)1042. 已知:class C {public static void main(String[] args) {int i = 1;boolean b = false;if(b && ++i == 2) {System.out.print( “first “ + i);} else {System.out.prin t( “second “ + i);}}}(A)first 1(B)first 2(C)second 1(D)second 243. 已知:class C {public static void main(String[] args) {String s = “Welcome to “;concat(s);System.out.print(s);}public static void concat(String s) {s += “Java”;}}则输出为(A)Welcome to(B)Welcome to Java(C)编译错误(D)运行时异常44. javax.swing.Timer将按一定频率产生什么事件(A)ActionEvent(B)TimerEvent(C)ItemEvent(D)InputEvent45. 下面哪种布局方式只影响控件的高度,而不影响宽度(A)BorderLayout 的WEST 和EAST(B)BorderLayout 的NORTH 和SOUTH(C)GridLayout(D)FlowLayout46. 已知:class C {public static void main(String[] args) {try {System.out.print(10 + 10 / 0);} catch(NullPointerException e1) {System.out.print( “a”);} catch(RuntimeException e2) {System.out.print( “b”);} finally {System.out.print( “c”);}}}(A)a(B)ac(C)bc(D)abc47. 已知:class C {public static String s = “c”;public static void main(String[] args) {C c = new C();B b = new B();System.out.print(C.s);System.out.print(B.s);System.out.print(c.s);System.out.print(b.s);System.out.print(((C)b).s);}}class B extends C {public static String s = “b”;}则输出为(A)ccccc(B)cbcbb(C)cbccc(D)cbcbc48. 已知:public class C {public static void main(String[] args) {print(new GraduateStudent());}public static void print(Object x) {System.out.println(x.toString());}}class Person {public String toString() {return “Person”;}}class Student extends Person {public String toString() {return “Student”;}}class GraduateStudent extends Student {}则输出为(A)GraduateStudent(B)Student(C)Person(D)Object49. 在JPanel 中绘图应覆盖哪个方法(A)paint(Graphics g)(B)paintComponent(Graphics g)(C)print(Graphics g)(D)repaint(Rectangle r)50. 下面哪个方法声明要求子类必须提供实现(A)public double m();(B)static void m() {}(C)abstract double m();(D)protected void m() {}51. 已知:class C {private int count = 0;public C () {count++;}public static void getCount() {return count;}public static void main(String[] args) {C c1 = new C();C c2 = new C();C c3 = new C();System.out.println(C.getCount());}则输出为(A)1(B)2(C)3(D)编译错误52. is-a 关系是指(A)继承关系(B)实现关系(C)关联关系(D)聚合关系53. 已知:class C {int x = 5;public void m(int x) {x += x;System.out.println(x);}public static void main(String[] args) {C c = new C();c.m(4);}}的输出为(A)8(B)9(C)10(D)编译错误54. 已知:interface I {int CONST = 3;void m(int i);}class C implements I {public static void main(String[] args) {int x = 5;new C().m(++x);}void m(int i) {System.out.println(CONST + i);}则输出为(A)8(B)9(C)编译错误(D)运行时异常55. 已知:interface Inter {void m();}abstract class Super {public abstract void m();}则下面哪段代码是合法的(A)class sub extends Super implements Inter {public void m() {}}(B)class sub extends Super implements Inter {public void m() {}public void Inter.m() {}}(C)class sub extends Super implements Inter {public void Super.m() {}public void m() {}}(D)class sub extends Super implements Inter {public void Inter.m() {}public void Super.m() {}}56. 已知:class C {public static void main(String[] args) {String[] s = {“one”, “two”, “three”};System.out.println(s.length > 0 ? s[0] : null);}}则输出为(A)one(B)two(C)three(D)null57. 已知:class C {public static void main(String[] args) {System.out.println( “null” instanceof Object);}}则输出为(A)null(B)true(C)String(D)Object58. 已知:class C {public static void main(String[] args) {int[] array = new int[10];increase(array);System.out.print(array[0]);}public static void increase(int[] array) {for(int i = 0; i < array.length; i++) {array[i]++;}}}则输出为(A)0(B)1(C)2(D)1059. this()表示(A)引用当前对象(B)调用当前对象(C)调用当前对象的方法(D)调用当前对象的构造函数60. 已知:package p;class C {public int x;}那么,在哪种情况下可以访问x(A)任意类(B)只有类C(C)只有类C 的子类(D)包p 中的类61. 已知:1 class C {2 private final int x;3 public C(int x) {4 this.x = x;5 }6 public int getX() {7 return x;8 }9 public void setX(int x) {10 this.x = x;11 }12 public static void main(String[] args) {13 C c = new C(5);14 c.setX(10);15 System.out.println(c.getX());16 }17 }则输出为(A)10(B)第4 行有编译错误(C)第10行有编译错误(D)第10行不起作用,数据字段x 的值保持不变62. 如果X extends Y, 那么(A)X 是接口,Y 是类(B)X 是类,Y 是接口(C)X 和Y 都是类,或者X 和Y 都是接口(D)X 和Y 是类和接口的任意组合63. 多态应用于(A)重载(B)覆盖(C)实现(D)组合64. 已知:1 class Crivitch {2 public static void main(String [] args) {3 int x = 0;4 ____________________5 do { } while (x++ < y);6 System.out.println(x);7 }8 }在第4 行插入哪句代码系统的输出是24(A)int y = 22(B)int y = 23(C)int y = 24(D)int y = 2565. 已知:class Animal {public abstract String noise();}class Dog extends Animal {public String noise() { return “wang wang”;} }class Cat extends Animal {public String noise() { return “miao miao”; } }class C {public static void main(String[] args) {Animal animal = new Cat();Dog dog = (Dog)animal;System.out.println(dog.noise());}}的输出为(A)wang wang(B)maio miao(C)编译错误(D)运行时异常66. 已知:class C {public static void main(String[] args) {String s = “123”;s += 123;System.out.println(s);}}的输出为(A)123(B)246(C)123123(D)编译错误67. 已知:class C {void add(int i) {add(++i);}public static void main(String[] args) {C c = new C();c.add(1);}}执行时会抛出哪种异常(A)StackOverflowError(B)IllegalArgumentException(C)NullPointerException(D)VirtualMachineError68. 已知:class C {public static void main(String[] args) {for(int i = 0; i <= 10; i++) {if(i > 7) {break;}}System.out.println(i);}}的输出为(A)7(B)8(C)10(D)编译错误69. 下面哪个类表示ponent 的键盘按下事件(A)KeyEvent(B)KeyPressedEvent(C)KeyDownEvent(D)KeyTypedEvent70. 已知:class C {public static void main(String[] args) {print();}public static void print() {static int i;System.out.println(++i);}}(A)0(B)1(C)编译错误(D)运行错误71. GUI 控件的事件处理中,事件源与监听器之间的关系是(A)一对一(B)一对多(C)多对一(D)多对多72. 已知:class C {public static void main(String[] args) {System.out.println(++i);}}在命令行中编译上面的代码,应使用(A)java C(B)java C.java(C)javac C(D)javac C.java73. 已知:class C {public static void main(String[] args) {String s = “Welcome to Java”;System.out.println(s.substring(2,3));}}则输出为(A)elc(B)el(C)l(D)lco74. 已知:class C {public static void main(String[] args) {String s = “Welcome”;s += “to”;s.concat( “Java”);System.out.println(s);}}则输出为(A)Welcome(B)Welcome to(C)Welcome to Java(D)编译错误75. 已知:class C {public static void main(String[] args) {System.out.println(9 ^ 2);}}则输出为(A)81(B)11(C)7(D)076. 下面哪个类表示在JTextField 的按Enter 键的事件(A)TextEvent(B)InputEvent(C)ActionEvent(D)KeyEvent77. 已知:class C {int i;String s;public C() {s += “world”;}public C(int i) {this.i = i;this.s = “Hello”;C();}public static void main(String[] args) {C c = new C(1);System.out.println(c.s);}}(A)Hello(B)Hello world(C)Hello world1(D)编译错误78. 已知:class C {public static void test(String s) {if(s == null | s.length() == 0) {System.out.println( “String is null”);} else {System.out.println( “String is not null”);}}public static void main(String[] args) {test(null);}}则输出为(A)String is null(B)String is not null(C)编译错误(D)运行时异常79. 已知:_________________class C {public static void main(String[] args) {System.out.println(sqrt(4));}}要使程序正确编译需要在横线处添加哪句代码(A)import ng.Math;(B)import ng.Math.*;(C)import static ng.Math;(D)import static ng.Math.*;80. 已知:class C {public static void main(String[] args) {for(int i = 1; i < args.length; i++) {System.out.print(args[i]);}}}在命令行中执行java C D E F则输入为(A)CDEF(B)DEF(C)EF(D)F多项选择题(60)81. swtich (expression)语句中表达式的类型可以是(A)String(B)char(C)short(D)double82. 设有方法:public A method() {…….return b;}则b 可以为(A)null(B)b 的类型为A(C)b 的类型为A 的子类(D)b 的类型为A 的父类83. 下面关于try、catch和finally语句块的组合使用,正确的是(A)try {,}(B)try {,} finally {,}(C)try {,} catch {,} finally {,}(D)try {,} catch {,} catch {,}84. 已知:interface I {int methodA();short methodB(byte s);}下面哪些代码是正确的?(A)abstract class C extends I {public int methodA() { return 0; }}(B)abstract class C implements I { }(C)interface I2 implements I{ }(D)class C extends I {int methodA() { return 0; }short methodB() { return 1; }}85. 下面的哪些声明是合法的?(A)int a[];(B)int a[5];(C)int[] a;(D)int a[] = [5];86. 已知:1 public class A {2 A m() { return this;}3 }4 class B extends A {5 _____________________6 }那么第5行可以添写?(A)A m() { return this;}(B)String m() { return this;}(C)int m(int i) { return 0;}(D)String m(int i) { return 0;}87. 如果a,b 是引用类型的变量,且赋值表达式A a = b;是正确的, 那么(A)表达式(b instanceof A)的值为true(B)b 的类型可以是A 的父类型(C)b 的值可以为null(D)如果A 为Object,那么b 可以是任何引用类型的变量88. 关于接口,描述正确的是(A)接口是抽象方法和常量值定义的集合(B)不相关的类可以实现同一接口(C)一个类只能实现一个接口(D)接口的成员方法不能提供实现代码89. 不必被捕获或声明抛出的异常是(A)NullPointerExcepiton(B)ArithmeticException(C)FileNotFoundException(D)RuntimeException90. 类与类之间的关系包括(A)关联关系(B)继承关系(C)组合关系(D)实现关系91. 下面类中属于字节I/O流的是(A)FileReader(B)FileInputStream(C)BufferedOutputStream(D)BufferedWriter92. 已知:1 class C {2 public static void main(String[] args) {3 String s = “- “ ;4 try {5 m(args[0]);6 s += “t “;7 } finally {8 System.out.println(s += “f “);9 }10 }11 public static void m(String a) {12 int y = 7 / Integer.parseInt(a);13 }14 }在命令行中输入:java Cjava C 0则(A)第6行会执行0 次(B)第8 行会执行1次(C)第12行会执行2 次(D)会抛出不同的异常93. 下面说法正确的是(A)继承表示is-a 的关系(B)继承表示has-a 的关系(C)要表示has-a 的关系必须使用接口(D)可以使用实例变量表示has-a 的关系94. 已知:class C {public static void a() {/*代码*/}public void b() {/*代码*/}}下面说法正确的是(A)可以在a 的代码中执行C.a()(B)可以在b 的代码中执行C.b()(C)可以在b 的代码中执行a()(D)可以在a 的代码中执行b()95. 已知:public abstract class Shape {private int x;private int y;public abstract void draw();public setLocation(int x, int y) {this.x = x;this.y = y;}}则下面的哪些代码是正确的(A)public class Circle implements Shape {private int radius;}(B)public abstract class Circle extends Shape {private int radius;}(C)public class Circle extends Shape {private int radius;public void draw();}(D)public class Circle extends Shape {private int radius;public void draw(){}}96. 下面哪些main 方法可用于程序执行(A)public static void main(String[] args) (B)public static void main(String[] x)(C)public static void main(String args[])(D)public void main(String[] args)97. 下面说法正确的是(A)实现同一接口的两个类之间是紧耦合的(B)封装可以提高类的重用性(C)封装好的类只允许子类覆盖方法,不允许子类重载方法(D)封装好的类允许修改方法的实现,而不影响外部代码98. 已知:class C {public static void main(String[] args) {String s = “Welcome to Java”;String s1 = new String(“Welcome to Java”);String s2 = s1.intern();String s3 = “Welcome to Java”;boolean b = __________________}}则在横线处添加哪些代码b 的值为true(A)s1 == s(B)s2 == s(C)s3 == s(D)s.equals(s1)99. 下面哪些语句是没有编译错误的(A)StringBuffer sb = “java”;(B)int i = 0x56;(C)Boolean b = new Boolean( “java”);(D)float f = 1.0;100.下面哪些类可用于throw语句(A)Error(B)Exception(C)Event(D)Throwable101.已知:____________________public class Base {}则下面哪些语句在横线处是合法的(A)package org.open;(B)import java.util.*;(C)class Derived {}(D)public static final CONTST = 1;102.已知:class C {int a = 1;public void m(final int b) {int c = 1;class Inner {public void mi(int d) {____________________}}Inner inner = new Inner();inner.mi(1);}}则下面哪个表达式在横线处是正确的(A)int e = a;(B)int e = b;(C)int e = c;(D)int e = d;103.下面哪个语句是正确的(A)short s = 256;(B)String s = …Hello world‟;(C)int x = 012;(D)char c = “a”;104.下面哪些标识符是合法的(A)s1(B)$1(C)_1(D)1s105.下面哪些说明是正确的(A)可以在类中定义类(B)可以在类中定义方法(C)可以在方法中定义类(D)可以在方法中定义方法106.已知:1 class Student {2 private String code;3 public Student(String code) {4 this.code = code;5 }6 public String getCode() {7 return code;8 }9 public boolean equals(Student s) {10 return code.equals(s.code)11 }12 }下面说法正确的是(A)第7行会产生编译错误,原因是不能访问private 成员变量code (B)当执行new Student.equals(new Object())时,会产生运行时异常(C)code在Student对象初始化后无法修改(D)Student.equals 方法不会覆盖Object.equals 方法107.下面哪些说法是正确的(A)一个控件上可以注册多个监听器(B)一个监听器只能注册到一个控件(C)一个类只能实现一个监听器接口(D)可以从控件上删除事件监听器108.下面哪些代码是正确的(A)File f = new File(“/”,”java.txt”);(B)DataInputStream d = new DataInputStream(System.in);(C)OutputStreamWriter o = new OutputStreamWriter(System.out); (D)RandomAccessFile r = new RandomAccessFile(“java.txt”);109.已知:class C {C c;_____________________}则下面的代码哪些在横线处是正确的(A)private class Inner {}(B)static class Inner() {}(C)C c2 = new C() {};(D)c = new C();110.已知:1 public interface I {2 int i = 1;3 }下面哪些语句是和第2 行等价的(A)public int i = 1;(B)static int i = 1;(C)final int i = 1;(D)abstract int i = 1;111.已知:class C implements Runnable {public void run() {System.out.println( “run”);throw new RuntimeException( “exception”);}public static void main(String[] args) {Thread t = new Thread(new C());t.start();System.out.println( “end”);}}则输出为(A)endrunng.RuntimeException:exception(B)runng.RuntimeException:exceptionend(C)runng.RuntimeException:exception(D)endng.RuntimeException:exceptionrun112.已知:class C {void m() {}}class B extends C {_______________}下面哪些语句在横线处是合法的(A)int void m() {}(B)private void m() {}(C)protected void m() {}(D)public void m() {}113.已知:class Rectangle {private int width, height;public void setSize(int width, int height) {this.width = width;this.height = height;}}下面哪些代码重载setSize方法(A)protected void setSize(int width, int height) {this(width, height)}(B)public void setSize(int width, float height) {this.width = width;this.height = (int)height;}(C)protected void setSize(int width) {this.width = width;}(D)public void setSize(int height, int width) {this.width = width;this.height = height;}114.哪些情况下线程会停止(A)调用该线程的halt 方法(B)调用该线程的stop方法(C)为另一个线程指定更高的优先级(D)调用System.exit(0);115.已知:class Base {}class Derived extends Base {static int i = 10;static float f = 10f;static char c = …a‟;public static void main(String[] args) {Base b = new Base();Derived d = new Derived();______________________}}下面哪些代码在横线处是合法的(A)d = b;(B)f = c;(C)c = i;(D)b = d;116.已知:interface I {void ma();void mb();void mc();}class Base {public void ma(){}}class Derived extends Base implements I {__________}要使Derived 通过编译需要添加下面哪些语句(A)public void ma() {}(B)void ma() {}(C)public void mb() {}(D)public void mc() {}117.下面哪些布局管理影响容器内控件的大小(A)GridLayout(B)BorderLayout(C)FlowLayout(D)GridBagLayout118.下面哪些代码可以正确编译(A)double d = 1.0;int i = 1;if(d == i) {System.out.println( “Hello world”);}(B)int i = 1;int j = 2;if(i = 1 && j = 2) {System.out.println( “Hello world”);}(C)boolean b1 = true, b2 = false;if(b1 == b2) {System.out.println( “Hello world”);}(D)int i = 0;if(i) {System.out.pri ntln( “Hello world”);}119.已知:class C {int i;________________}下面哪些语法在横线处是合法的(A)i++;(B)void m(int i){}(C)class B extends C{}(D)System.out.println(i);120.下面哪些类型实现了Comparable 接口(A)Integer(B)double(C)String(D)Object121.已知:class Base {void m() {}}class Derived extends Base {________________________}则在横线处哪些语句是合法的(A)private void m() {}(B)protected void m() {}(C)public void m() {}(D)public void m(int i) {}122.已知:class C {public static void main(String[] args) {String[] s = new String[10];___________________________ }}则下面的说明哪些是正确的(A)s[0]的值为”“(B)s[3] + s[4]的值为“nullnull”(C)s[10]的值为null(D)s.length 的值10123.已知:class C {int x = 100;public void m(int x) {System.out.println(___________);}public static void main(String[] args) {C c = new C();c.m(0);}}如果程序输出101,则在横线处填写下面哪些代码(A)x++(B)++x(C)++this.x(D)this.x + 1124.下面哪些方法禁止子类重定义该方法(A)protected void m() {}(B)final void m() {}(C)abstract final void m() {}(D)static final void m() {}125.下面哪些控件可以产生ActionEvent(A)javax.swing.JButton(B)javax.swing.JTextBox(C)javax.swing.JList(D)javax.swing.Timer126.已知:class C {public C(int i) {}}下面哪些代码是对构造函数的重载(A)C() {}(B)public Object C(byte b) {}(C)public void C() {}(D)private C(int i, int j) {}127.下面哪些类属于轻型组件(A)JFrame(B)JLabel(C)JButton(D)JTree128.已知:class C {public static void main(String[] args) {try {method();System.out.pri ntln(“a”);} catch (ArithmeticException e) {System.out.println(“b”);} finally {System.out.println(“c”);}System.out.println(“d”);}static void method () {throw new NullPointerException();}}则输出包含(A)a(B)b(C)c(D)d129.下面哪些说法是正确的(A)静态方法不能被覆盖(B)私有方法不能被重载(C)实例变量能够被隐藏(D)静态方法能够被重载130.已知:class C {public static void main(String[] args) {int[] a = new int[10];_____________________}}下面哪些语句在横线处可以正常编译(A)int i = a.length();(B)int i = a[10];(C)int i = a.getAt(0);131.下面哪些类型属于Java基本数据类型(A)int(B)Boolean(C)uint(D)double132.已知String s = “Java”,则下面哪些代码是正确的(A)s = s + 1;(B)char c = s[3];(C)int i = s.length;(D)String t = s + new Object();133.下面说法正确的是(A)当且仅当类C 是抽象类时,才能包含final方法(B)类C 中的protected 实例方法可以被子类覆盖(C)类C 中的private 静态方法只能被类C 中的其它静态方法调用(D)类C 中的public 静态方法可以被子类直接访问,而不需要用类名引用方法134.已知:1 class C {2 private int i;3 protected C(int i) { this.i = i; }4 }5 class B extends C {6 public B() { this.i = 5; }7 public B(int i) { super(i); }8 }要使用类B 通过编译,只需要修改(A)第2行改为:public int i;(B)第3行改为:public C(int i) { this.i = i; }(C)第6行改为:public B() { this(5); }(D)第6行改为:public B() { super(5); }135.下面选项中哪些不是Java 关键字(A)NULL(B)instanceof(C)sizeof(D)interface136.下面哪些代码中声明的变量可以存放10个String对象(A)String[] a;(B)Object[] a;。