娄底匝丝投资有限公司

在線留言 注冊 登錄
熱門搜索:形考答案免費(fèi)答案奧鵬答案

東大25春《JAVA語言程序設(shè)計(jì)ⅡX》在線平時(shí)作業(yè)2【標(biāo)準(zhǔn)答案】

Time2025-04-25Hits瀏覽量: 8
有奧鵬院校所有作業(yè)、畢業(yè)論文,詳情請咨詢請?zhí)砑観Q : 103092222或微信: xyzlfx100

《JAVA語言程序設(shè)計(jì)Ⅰ》在線平時(shí)作業(yè)2-00001

試卷總分:100  得分:100

一、單選題 (共 20 道試題,共 60 分)

1.下列語句序列執(zhí)行后,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


2.如果你有下面的類定義 abstract class Shape{ abstract void draw(); } 請問,在試圖編譯下面的類定義時(shí)會發(fā)生什么情況? class Square extends Shape{ }

A.都可以成功編譯

B.Shpe可以編譯,而Square不能

C.Square可以編譯,而Shape不能

D.Shape和Square都不能編譯


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

A.創(chuàng)建一個(gè)數(shù)組類對象MyVector,有100個(gè)元素的空間,每個(gè)元素的初值為50。

B.創(chuàng)建一個(gè)向量類對象MyVector,有100個(gè)元素的空間,每個(gè)元素的初值為50。

C.創(chuàng)建一個(gè)數(shù)組類對象MyVector,有100個(gè)元素的空間,若空間使用完時(shí),以50個(gè)元素空間單位遞增。

D.創(chuàng)建一個(gè)向量類對象MyVector,有100個(gè)元素的空間,若空間使用完時(shí),以50個(gè)元素空間單位遞增。


4.下列代碼中,將引起一個(gè)編譯錯誤的行是 1)public class Test{ 2) int m,n; 3) public Test() {} 4) public Test(int a) {m=a;} 5) public static void main(String args[]){ 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

A.第3行

B.第5行

C.第6行

D.第10行


5.Person, Student 和Teacher 都是類名。這些類有以下繼承關(guān)系。 Person | -------------------- | | Student Teacher 并且在Java源代碼中有如下表達(dá)式: Person p = new Student(); 如下哪個(gè)語句是正確的?

A.這條語句是合法的

B.這條語句是不合法的

C.編譯時(shí)出錯

D.編譯正確但運(yùn)行時(shí)出錯


6.閱讀下列代碼后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正確的說法是

A.編譯時(shí)將產(chǎn)生錯誤

B.編譯時(shí)正確,運(yùn)行時(shí)將產(chǎn)生錯誤

C.輸出零

D.輸出空


7.下面哪一個(gè)類可以訪問foo包中的所有變量? package foo; class a{int c} class b{private int d} class c{public int e}

A.class a

B.class b

C.class c

D.都不能


8.若有循環(huán): int x=5,y=20; do{ y-=x; x++; }while(++x<--y);則循環(huán)體將被執(zhí)行( )。

A.0次

B.1次

C.2次

D.3次


9.下列語句序列執(zhí)行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; }

A.15

B.16

C.17

D.18


10.下列代碼的執(zhí)行結(jié)果是 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.運(yùn)行成功,但不輸出


11.設(shè)有下面的一個(gè)類定義: class AA { static void Show( ){ System.out.println("我喜歡Java!"); } } class BB { void Show( ){ System.out.println("我喜歡C++!"); } } 若已經(jīng)使用AA類創(chuàng)建對象a和BB類創(chuàng)建對象b,則下面哪一個(gè)方法調(diào)用是正確的:( )

A.Show( ) b.Show( )

B.AA.Show( ) BB.Show( )

C.AA.Show( ) b.Show( )

D.Show( ) BB.Show( )


12.給定下面的類:   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


13.下面程序的輸出結(jié)果是什么? 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.運(yùn)行時(shí)出現(xiàn)異常


14.下面的代碼段中,執(zhí)行之后i 和j 的值是什么? int i = 1; int j; j = i++;

A.1, 1

B.1, 2

C.2, 1

D.2, 2


15.下列程序段執(zhí)行后t5的結(jié)果是( )。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


16.給出下列的代碼,哪行在編譯時(shí)可能會有錯誤? ① 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


17.給出下面的接口: interface A{ int method1(int i); int method2(int j); } 下面那個(gè)類實(shí)現(xiàn)了這個(gè)接口,并且不是抽象的?

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){} }


18.下面的哪些程序段可以正確地獲得從命令行傳遞的參數(shù)的個(gè)數(shù)?

A.int count = args.length;

B.int count = args.length-1;

C.int count=0; while(args[count]!=null) count++;

D.int count=0;while (!(args[count].equals(“”))) count++;


19.以下代碼的輸出結(jié)果是什么? 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.編譯錯誤


20.已知表達(dá)式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪個(gè)表達(dá)式的值與數(shù)組下標(biāo)量總數(shù)相等?

A.length()

B.length

C.length()+1

D.length+1


二、多選題 (共 10 道試題,共 40 分)

21.已知如下定義: String s = "story"; 下面哪些表達(dá)式是合法的?

A.s += "books";

B.char c = s[1];

C.int len = s.length;

D.String t = s.toLowerCase();


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.下面的哪些程序片斷可能導(dǎo)致錯誤。

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.假定文件名是“Fred.java”,下面哪個(gè)是正確的類聲明。

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; }


25.在如下源代碼文件Test.java中, 哪個(gè)是正確的類定義?

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.你怎樣從下面main()的調(diào)用中訪問單詞“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]


27.如果有以下代碼,哪幾個(gè)數(shù)字能產(chǎn)生輸出 "Test2" 的結(jié)果? Switch(x){ case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break;} System.out.println("Test3"); }

A.0

B.1

C.2

D.3


28.已知如下類說明: 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(); // 程序代碼… } } 如下哪個(gè)使用是正確的?

A.t.f

B.this.n

C.Test.m

D.Test.n


29.給出下面的代碼段: 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);


30.請選出創(chuàng)建數(shù)組的正確語句。

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];


吐血推薦

奧鵬,國開形考,廣開,電大在線,各省平臺,新疆一體化,各類成人教育等學(xué)習(xí)。詳情請咨詢QQ : 103092222或微信: xyzlfx100

添加微信查看答案

東大25春《JAVA語言程序設(shè)計(jì)ⅡX》在線平時(shí)作業(yè)2【標(biāo)準(zhǔn)答案】_學(xué)優(yōu)資料分享網(wǎng)

添加微信二維碼,了解更多學(xué)習(xí)技巧,平 臺作業(yè)、畢業(yè)論文完成時(shí)間友情提醒。。

合作洽談

誠信為本,合作共贏

歡迎各大學(xué)習(xí)中心前來治談;有意請聯(lián)系我們

推薦作業(yè)

留言板
captcha
感謝留言
我們會盡快與您聯(lián)系
關(guān)閉