详情请咨询QQ:3494317897 微信:aopy98
《JAVA语言程序设计Ⅰ》在线平时作业3-00001 试卷总分:100 得分:100 一、单选题 (共 20 道试题,共 60 分) 1.以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } } A.1 B.2 C.3 D.编译错误
2.下列程序段执行后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
3.设有下面两个赋值语句: a = Integer.parseInt("1024"); b = Integer.valueOf("1024").intValue(); 下述说法正确的是( )。 A.a是整数类型变量,b是整数类对象。 B.a是整数类对象,b是整数类型变量。 C.a和b都是整数类对象并且它们的值相等。 D.a和b都是整数类型变量并且它们的值相等。
4.在程序的源文件开始处有下面一行程序: package awt; A.结果是一个编译错误,因为Java已经定义了一个awt包 B.说明这个文件里的所有的类都应该包含在java.awt包里 C.说明这个文件里的所有的类都应该包含在自己定义的awt包里 D.导入你自己定义的awt包里的所有类
5.下列语句序列执行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; } A.15 B.16 C.17 D.18
6.选择正确的叙述. class Happy extends Frame { Happy() { SetLayout(new GridLayout(2,2)); Panel p1 = new Panel(); add(p1); p1.add( new Button("One")); Panel p2 = new Panel(); add(p2); p2.add( new Button("Two")); add( new Button("Three")); add( new Button("Four")); s A.当frame调整大小时,按钮Three和Four 的大小也将调整。 B.当frame调整大小时,所有按钮的大小都将调整。 C.当frame调整大小时,按钮Two和Four 的大小也将调整。 D.当frame调整大小时,按钮One和Two 的大小也将调整。
7.以下由do-while语句构成的循环执行的次数是( )。 int k = 0; do { ++k; }while ( k < 1 ); A.一次也不执行 B.执行1次 C.无限次 D.有语法错,不能执行
8.下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new Te A.0 B.1 C.2 D.3
9.已知如下代码: boolean m = true; if ( m = false ) System.out.println("False"); else System.out.println("True"); 执行结果是什么? A.False B.True C.编译时出错 D.运行时出错
10.65. 已知有下列类的说明,则下列哪个语句是正确的? public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); } } A.t.f; B.this.n; C.Test.m; D.Test.f;
11.下面程序的输出结果是什么? class Happy { public static void main(String args[]) { int i =1; int j = 10; do { if ( i++ < j--) continue; } while ( i <5 ); System.out.println ( i+" "+j ); } } A.5 5 B.5 4 C.6 4 D.5 6
12.下面程序运行后I的结果是什么? Class sree { fun(){ static int I =0; I++; } public static void main(String args[]) { sree obj=new sree(); obj.fun(); obj.fun(); } A.编译错误 B.运行时错误 C.1 D.2
13.给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { ... } } A.将private int m 改为protected int m B.将private int m 改为 public int m C.将private int m 改为 static int m D.将private int m 改为 int m
14.已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪个表达式的值与数组下标量总数相等? A.length() B.length C.length()+1 D.length+1
15.若a的值为3时,下列程序段被执行后,c的值是多少?( ) c = 1; if ( a>0 ) if ( a>3 ) c = 2; else c = 3; else c = 4; A.1 B.2 C.3 D.4
16.下列代码的执行结果是 public class Test { public int aMethod() { static int i=0; i++; System.out.println(i); } public static void main(String args[]) { Test test = new Test(); A.编译错误 B.0 C.1 D.运行成功,但不输出
17.下列语句序列执行后,k 的值是( )。 int x=6, y=10, k=5; switch( x%y ) { case 0: k=x*y; case 6: k=x/y; case 12: k=x-y; default: k=x*y-x; } A.60 B.54 C.0 D.5
18.下面语句返回的数据类型是什么? (short)10/10.2*2; A.int B.double C.float D.short
19.设有下面的一个类定义: class AA { static void Show( ){ System.out.println("我喜欢Java!"); } } class BB { void Show( ){ System.out.println("我喜欢C++!"); } } 若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:( ) A.Show( ) b.Show( ) B.AA.Show( ) BB.Show( ) C.AA.Show( ) b.Show( ) D.Show( ) BB.Show( )
20.如果你有下面的类定义 abstract class Shape{ abstract void draw(); } 请问,在试图编译下面的类定义时会发生什么情况? class Square extends Shape{ } A.都可以成功编译 B.Shpe可以编译,而Square不能 C.Square可以编译,而Shape不能 D.Shape和Square都不能编译
二、多选题 (共 10 道试题,共 40 分) 21.已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中? A.private void fun( int n ){ //...} B.void fun ( int n ){ //... } C.protected void fun ( int n ) { //... } D.public void fun ( int n ) { //... }
22.请选出创建数组的正确语句。 A.float f[][] = new float[6][6]; B.float []f[] = new float[6][6]; C.float f[][] = new float[][6]; D.float [][]f = new float[6][6];
23.下面的哪些程序片断可能导致错误。 A.String s="Gonewiththewind"; String t="good"; String k=s+t; B.String s="Gonewiththewind"; String t; t=s[3]+"one"; C.String s="Gonewiththewind"; String standard=s.toUpperCase(); D.String s="homedirectory"; String t=s-"directory".
24.选择所有有效的构造函数。 class Happy { } } A.public void Happy(){} B.public Happy(int c){} C.protected Happy(){} D.public int Happy(){} E.void Happy(){}
25.你怎样从下面main()的调用中访问单词“kiss”? java lyrics a kiss is but a kiss A.args[0] B.args[1] C.args[2] D.args[3] E.args[4] F.args[5]
26.在如下源代码文件Test.java中, 哪个是正确的类定义? A.public class test { public int x = 0; public test(int x) { this.x = x; } } B.public class Test{ public int x=0; public Test(int x) { this.x = x; } } C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } } D.public class
27.已知如下代码: 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 的 A.0 B.1 C.2 D.3 E.4 F.以上都不是
28.已知如下代码: public class Test { public static void main(String arg[]) { int i = 5; do { System.out.println(i); } while (--i>5) System.out.println("finished"); } } 执行后的输出结果包括什么? A.5 B.4 C.6 D.finished E.什么都不输出
29.下面代码执行后的输出是什么? outer: for(int i=0;i<3; i++) inner: for(int j=0;j<2;j++) { if(j==1) continue outer; System.out.println(j+ “ and “+i); } A.0 and 0 B.0 and 1 C.0 and 2 D.1 and 0 E.1 and 1 F.1 and 2 G.2 and 0 H.2 and 1 I.2 and 2
30.针对下面的程序,那些表达式的值是true? Class Aclass{ private long val; public Aclass(long v){val=v;} public static void main(String args[]){ Aclass x=new Aclass(10L); Aclass y=new Aclass(10L); Aclass z=y; long a=10L; int b=10; } } A.a==b; B.a==x; C.y==z; D.x==y; E.a==10.0;
奥鹏,国开,广开,电大在线,各省平台,新疆一体化等平台学习
详情请咨询QQ:3494317897 微信:aopy98 |