在线留言 注册 登录
热门搜索:形考答案免费答案奥鹏答案

东大25春《JAVA语言程序设计ⅡX》在线平时作业1【标准答案】

Time2025-04-25Hits浏览量: 8
有奥鹏院校所有作业、毕业论文,详情请咨询请添加QQ : 103092222或微信: xyzlfx100

《JAVA语言程序设计Ⅰ》在线平时作业1-00001

试卷总分:100  得分:100

一、单选题 (共 20 道试题,共 60 分)

1.若有循环: int x=5,y=20; do{ y-=x; x++; }while(++x<--y);则循环体将被执行( )。

A.0次

B.1次

C.2次

D.3次


2.下列代码的执行结果是 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.运行成功,但不输出


3.顺序执行下列程序语句后,则b的值是 String a="Hello"; String b=a.substring(0,2);

A.Hello

B.hello

C.Hel

D.null


4.给出下列代码,如何使成员变量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


5.已知如下代码: boolean m = true; if ( m = false ) System.out.println("False"); else System.out.println("True"); 执行结果是什么?

A.False

B.True

C.编译时出错

D.运行时出错


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

A.length()

B.length

C.length()+1

D.length+1


7.下列语句序列执行后,j 的值是( )。 Int j=3, i=2; while( --i!=i/j ) j=j+2;

A.2

B.4

C.5

D.6


8.设有下面的两个类定义: 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++!


9.在oneMethod()方法运行正常的情况下,程序段将输出什么? public void test() { try { oneMethod(); System.out.println("condition 1"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("condition 2"); } catch(Exception e) { System.out.println("condition 3");

A.condition 1

B.condition 2

C.condition 3

D.condition 1 finally


10.下面程序的输出结果是什么? 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


11.下面程序的输出结果是什么? class Foo{ static void change(String s){ s=s.replace('j','l'); } public static void main(String args[]){ String s="java"; change(s); System.out.println(s); } }

A.lava

B.java

C.编译错误

D.运行时出现异常


12.下列语句序列执行后,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


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

A.1, 1

B.1, 2

C.2, 1

D.2, 2


14.下面的语句的作用是:( )。 Vector MyVector = new Vector(100,50);

A.创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。

B.创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。

C.创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。

D.创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。


15.给定下面的类:   public class Example{   String str=new String(“good”);   char ch[]={'a','b','c'};   public static void main(String args[]){   Example ex=new Example();   ex.change(ex.str,ex.ch);   System.out.println(ex.str+”and”+ex.ch);   }   public void

A.good and abc

B.good and gbc

C.test ok and abc

D.test ok and gbc


16.下面程序的输出结果是什么? public static void main(String args[]) { int a=10; int b=20; if(a=b) System.out.println("Not Equal"); else System.out.println("Equal"); }

A.Equal

B.Not Equal

C.编译错误

D.运行时将抛出异常


17.请选择以下代码的正确的重载构造器。 class Happy { Happy() { } }

A.public void Happy(){}

B.public Happy(int c){}

C.protected Happy(){}

D.void Happy(){}


18.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;


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


20.下列程序的功能是在监控台上每隔一秒钟显示一个字符串“Hello”,能够填写在程序中下划线位置,使程序完整并能正确运行的语句是 public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try{

A.sleep(1000) InterruptedException

B.sleep(1000) RuntimeException

C.Thread.sleep(1000) RuntimeException

D.Thread.sleep(1000) InterruptedException


二、多选题 (共 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.String s=”Example String”; 下面哪些语句是正确的?

A.s>>>=3;

B.int i=s.length();

C.s[3]=”x”;

D.String short_s=s.trim();

E.String t=”root”+s;


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


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


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.假定文件名是“Fred.java”,下面哪个是正确的类声明。

A.public class Fred{   public int x = 0;   public Fred (int x){   this.x=x;   }   }

B.public class fred{   public int x = 0;   public Fred (int x){   this.x=x;   }   }

C.public class Fred extends MyBaseClass{   public int x = 0; }


27.下面代码执行后的输出是什么? 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


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.针对下面的程序,那些表达式的值是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;


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



吐血推荐

奥鹏,国开形考,广开,电大在线,各省平台,新疆一体化,各类成人教育等学习。详情请咨询QQ : 103092222或微信: xyzlfx100

添加微信查看答案

东大25春《JAVA语言程序设计ⅡX》在线平时作业1【标准答案】_学优资料分享网

添加微信二维码,了解更多学习技巧,平 台作业、毕业论文完成时间友情提醒。。

合作洽谈

诚信为本,合作共赢

欢迎各大学习中心前来治谈;有意请联系我们

推荐作业

留言板
captcha
感谢留言
我们会尽快与您联系
关闭