1、清华大学java试题卷3份含答案清华大学java试题卷3份(含答案)一、 选择是int型public成员变量, 变量值保持为常量100,用简短语句定义这个变量。 A public int MAX_LENGTH=100; B final int MAX_LENGTH=100; C final public int MAX_LENGTH=100; D public final int MAX_LENGTH=100. 2.给出下面代码:1) class Parent 2) private String name; 3) public Parent() 4) 5) public class Child
2、 extends Parent 6) private String department; 7) public Child() 8) public String getValue() return name; 9) public static void main(String arg) 10) Parent p = new Parent(); 11) 12) 那些行将引起错误 A 第3行 B 第6行 C 第7行 D 第8行3.类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; if(t instanceof Person)
3、s = (Student)t; 最后一句语句的结果是: A 将构造一个Student对象; B 表达式是合法的; C 表达式是错误的; D 编译时正确,但运行时错误。 4.给出下面代码段 1) public class Test 2) int m, n; 3) public Test() 4) public Test(int a) m=a; 5) public static void main(String arg) 6) Test t1,t2; 7) int j,k; 8) j=0; k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) 12) 哪
4、行将引起一个编译时错误 A line 3 B line 5 C line 6 D line 10 5.对于下列代码: 1) class Person 2) public void printValue(int i, int j) 3) public void printValue(int i) 4) 5) public class Teacher extends Person 6) public void printValue() 7) public void printValue(int i) 8) public static void main(String args) 9) Person
5、 t = new Teacher(); 10) (10); 11) 第10行语句将调用哪行语句 A line 2 B line 3 C line 6 D line 76.哪个关键字可以抛出异常 A transient B finally C throw D static ()方法的返回类型是: A int B void C boolean D static 类在哪个包中 A B C D 9.对于下列代码: public class Parent public int addValue( int a, int b) int s; s = a+b; return s; class Child ex
6、tends Parent 下述哪些方法可以加入类Child A int addValue( int a, int b ). B public void addValue (int a, int b ). C public int addValue( int a ). D public int addValue( int a, int b )throws MyException . 10.给出下面代码: public class test static int a = new a10; public static void main(String args) 那个选项是正确的 A 编译时将产生错
7、误; B 编译时正确,运行时将产生错误; C 输出零; D 输出空。 11.下面哪些选项是正确的main方法说明 A public main(String args) B public static void main(String args) C private static void main(String args) D void main() 窗体底端窗体顶端二、多项选择1.下面哪些代码段是正确的Java源程序 A. package testpackage; public class Test.B. import .*; package testpackage; public clas
8、s Test.C. import .*; class Person. public class Test.D. import .*; import .*; public class Test.2.public class parent int change() class Child extends Parent 哪些方法可加入类Child中 A public int change() B int chang(int i) C private int change() D abstract int chang() 3.String s = hello; String t = hello; ch
9、ar c = h,e,l,l,o ; 下列哪些表达式返回true A (t); B (c); C s=t; D (new String(hello); 4.给出下面代码段: 1) switch(m) 2) case 0: case 0); 3) case 1: case 1); break; 4) case 2: 5) default: default); 6) 下列m的哪些值将引起default的输出 A 0 B 1 C 2 D 3 5.下列哪些说法是正确的 A Java 语言只允许单一继承 B Java 语言只允许实现一个接口 C Java 语言不允许同时继承一个类并实现一个接口 D Ja
10、va 语言的单一继承使得代码更加可靠 6.下列关于的运算,哪些是正确的 A 0000 0100 0000 0000 0000 0000 0000 00005 的运行结果是 1000 0000 0000 0000 0000 0000 0000 0000 B 0000 0100 0000 0000 0000 0000 0000 00005的运行结果是 1111 1110 0000 0000 0000 0000 0000 0000 D 1100 0000 0000 0000 0000 0000 0000 00005的运行结果是 0000 0110 0000 0000 0000 0000 0000 0
11、000 7.下述哪些说法是正确的 A 实例变量是类的成员变量 B 实例变量是用static关键字声明的 C 方法变量在方法执行时创建 D 方法变量在使用之前必须初始化 8.对于下列代码: public class Sample long 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
12、s1 = = s2; B s2 = = s3; C m = = s1; D (m)9.下面说法哪些是正确的 A Applet可以访问本地文件 B 对static方法的调用不需要类实例 C socket类在中 D 地址代表本机 10.下列说法正确的是: A java语言里的线程是没有优先级的 B String类在包中 C java语言支持类的序列化 D 能序列化的类必须实现接口11.关于awt和swing说法正确的是: A awt在不同操作系统中显示相同的风格。 B swing在不同的操作系统中显示相同的风格 C 的子类 D awt和swing都支持事件模型 12.关于Float,下列说法正确的是 A Float是一个类 B Float在包中 C Float a=是正确的赋值方法 D Float a= new Float是正确的赋值方法 13.下述哪些说法是正确的 A java语言中的类只能有一个构造函数 B 程序员可以自己定义自己的异常 C java语言允许多继承 D socket在包中14.下列哪些说法是正确的 A IOException必须
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1