最新消息:可做奥鹏等各院校作业论文,答案请联系QQ/微信:18866732

东大23秋学期《JAVA语言程序设计Ⅰ》在线平时作业1【参考答案】

《JAVA语言程序设计Ⅰ》在线平时作业1-00001
试卷总分:100 得分:100
一、单选题 (共 20 道试题,共 60 分)
1.设有下面的两个类定义: class AA { void Show(){ System.out.println(“我喜欢Java!”); } class BB extends AA { void Show(){ System.out.println(“我喜欢C++!”); } 则顺序执行如下语句后输出结果为:( ) AA a; BB b; a.Show(); b.Show();
A.我喜欢Java! 我喜欢C++!
B.我喜欢C++! 我喜欢Java!
C.我喜欢Java! 我喜欢Java!
D.我喜欢C++! 我喜欢C++!

2.下列哪个选项的java源文件代码片段是不正确的?
A.package testpackage; public class Test{ }
B.import java.io.*; package testpackage; public class Test{ }
C.import java.io.*; class Person{ } public class Test{ }
D.import java.io.*; import java.awt.*; public class Test{ }

3.给出下列代码,则数组初始化中哪项是不正确的? byte[] array1,array2[]; byte array3[][]; byte [][] array4;
A.array2 = array1
B.array2=array3
C.array2=array4
D.array3=array4

4.下面程序运行后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

5.给出下列的代码,哪行在编译时可能会有错误? ① public void modify(){ ② int i, j, k; ③ i = 100; ④ while ( i > 0 ){ ⑤ j = i * 2; ⑥ System.out.println (” The value of j is ” + j ); ⑦ k = k + 1; ⑧ } ⑨ }
A.4
B.6
C.7
D.8

6.在程序的源文件开始处有下面一行程序: package awt;
A.结果是一个编译错误,因为Java已经定义了一个awt包
B.说明这个文件里的所有的类都应该包含在java.awt包里
C.说明这个文件里的所有的类都应该包含在自己定义的awt包里
D.导入你自己定义的awt包里的所有类

7.已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪个表达式的值与数组下标量总数相等?
A.length()
B.length
C.length()+1
D.length+1

8.阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出零
D.输出空
奥鹏作业答案请进open5.net或请联系QQ/微信:18866732
9.下列类头定义中,错误的是( )。
A.class x { …. }
B.public x extends y { …. }
C.public class x extends y { …. }
D.class x extends y implements y1 { …. }

10.以下代码的输出结果是什么? 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.编译错误

11.若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

12.下面程序的输出结果是什么? String s= “ABCD”; s.concat(“E”); s.replace(‘C’,’F’); System.out.println(s);
A.编译错误,字符串是不可改变的
B.ABFDE
C.ABCDE
D.ABCD

13.下面的代码段中,执行之后i 和j 的值是什么? int i = 1; int j; j = i++;
A.1, 1
B.1, 2
C.2, 1
D.2, 2

14.给出下面的接口: interface A{ int method1(int i); int method2(int j); } 下面那个类实现了这个接口,并且不是抽象的?
A.class B implements A{ int method1(){} int method2(){} }
B.class B { int method1(int i){} int method2(int j){} }
C.class B implements A{ int method1(int i){} int method2(int j){} }
D.class B extends A{ int method1(int i){} int method2(int j){} }

15.请选择以下代码的正确的重载构造器。 class Happy { Happy() { } }
A.public void Happy(){}
B.public Happy(int c){}
C.protected Happy(){}
D.void Happy(){}

16.下列语句序列执行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; }
A.15
B.16
C.17
D.18

17.设有下面的一个类定义: 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( )

18.如果你有下面的类定义 abstract class Shape{ abstract void draw(); } 请问,在试图编译下面的类定义时会发生什么情况? class Square extends Shape{ }
A.都可以成功编译
B.Shpe可以编译,而Square不能
C.Square可以编译,而Shape不能
D.Shape和Square都不能编译

19.已知如下代码: boolean m = true; if ( m = false ) System.out.println(“False”); else System.out.println(“True”); 执行结果是什么?
A.False
B.True
C.编译时出错
D.运行时出错

20.下列语句序列执行后,j 的值是( )。 Int j=3, i=2; while( –i!=i/j ) j=j+2;
A.2
B.4
C.5
D.6

二、多选题 (共 10 道试题,共 40 分)
21.已知如下代码: 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.以上都不是

22.已知如下类说明: 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.n

23.已知如下定义: String s = “story”; 下面哪些表达式是合法的?
A.s += “books”;
B.char c = s[1];
C.int len = s.length;
D.String t = s.toLowerCase();

24.给出下面的代码段: public class Base{ int w, x, y ,z; public Base(int a,int b) { x=a; y=b; } public Base(int a, int b, int c, int d) { //赋值 x=a, y=b w=d; z=c; } } 在代码说明//赋值 x=a, y=b处写入如下哪几行代码是正确的?
A.Base(a,b)
B.x=a,y=b;
C.x=a;y=b;
D.this(a,b);

25.在如下源代码文件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

26.下面的哪些程序片断可能导致错误。
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”.

27.你怎样从下面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]

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.已知如下类定义: 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 ) { //… }

30.选择所有有效的构造函数。 class Happy { } }
A.public void Happy(){}
B.public Happy(int c){}
C.protected Happy(){}
D.public int Happy(){}
E.void Happy(){}

转载请注明:奥鹏作业之家 » 东大23秋学期《JAVA语言程序设计Ⅰ》在线平时作业1【参考答案】

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址