達內(nèi)Java1609班第一次月考_第1頁
達內(nèi)Java1609班第一次月考_第2頁
達內(nèi)Java1609班第一次月考_第3頁
達內(nèi)Java1609班第一次月考_第4頁
達內(nèi)Java1609班第一次月考_第5頁
已閱讀5頁,還剩43頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、·1.·(單選題)下列數(shù)組聲明語句中,錯誤的是:()。··  A.int arr = new int;··  B.int arr = new int;··  C.int arr = ;··  D.int arr = new int2;·正確答案:B。·2.·(單選)class Card下列不屬于Card類構(gòu)造方法的是:()··  A.Card()··  B.publi

2、c Card()··  C.public void Card()··  D.private Card()·正確答案:C·3.·(單選)下面不屬于Java語言特點的是:··  A.平臺無關(guān)··  B.面向?qū)ο?#183;·  C.支持指針類型··  D.垃圾回收機制·正確答案:C·4.·(單選)下列選項中的類,能正確實現(xiàn)java.lang.Runnable接口和java

3、.lang.Clonable接口的是()。··  A.public class Session implements Runnable, Clonable public void run(); public Object clone(); ··  B.public class Session implements Runnable, implements Clonable public void run() / do something */ public Object clone() / make a copy */ ·&

4、#183;  C.public class Session implements Runnable, Clonable public void run() / do something */ public Object clone() /* make a copy */ ··  D.public class Session extends Runnable, Clonable public void run() ; public Object clone(); ·正確答案:C·5.·(單選)下列屬于不合法Java標(biāo)識符的是(

5、)。··  A._mem··  B.12a··  C.M12··  D.$12·正確答案:B·6.·(單選)下列Java標(biāo)識符,錯誤的是()··  A._sys_varl··  B.$change··  C.User_name··  D.1_file·正確答案:D·7.·(單選)Java程序的執(zhí)行過

6、程中用到一套JDK工具,其中javac.exe是指()。··  A.Java語言編譯器··  B.Java字節(jié)碼解釋器··  C.Java文檔生成器··  D.Java類分解器·正確答案:A·8.·(單選)運行下列代碼: int oneArr = 2, 11, 26, 27, 37, 44, 48, 60 ; int twoArr = 19, 35, 49, 55, 58, 75, 83, 84, 91, 93 ; int threeArr =

7、new intoneArr.length + twoArr.length; int p = 0, q = 0; while (p < oneArr.length && q < twoArr.length) threeArrp + q = oneArrp < twoArrq ? oneArrp+ : twoArrq+; if (p < oneArr.length) System.arraycopy(oneArr, p, threeArr, p + q, oneArr.length - p); else if (q < twoArr.length) S

8、ystem.arraycopy(twoArr, q, threeArr, p + q, twoArr.length - q); System.out.println(Arrays.toString(threeArr); 輸出的結(jié)果是:()。··  A.2,11,26,27,37,44,48,60,19,35,49,55,58,75,83,84,91,93;··  B.2,11,19,26,27,35,37,44,48,49,55,58,60,75,83,84,91,93;··  C.19,35,49,55

9、,58,75,83,84,91,93,2,11,26,27,37,44,48,60;··  D.2,19,11,35,26,49,27,55,37,58,44,75,48,83,60,84,91,93;·正確答案:B·9.·(單選)A類中有一個方法:protected int print(String str),B類繼承A類, 以下方法能在B類中重寫A類中print()方法的是: ()。··  A.public int print(String str)··  B.priva

10、te int print(String str)··  C.private void print(String str)··  D.public void print(String str)·正確答案:A·10.·(單選)下列代碼的輸出結(jié)果是()。 boolean b=true?false:true=true?false:true; System.out.println(b);··  A.true··  B.false·· &

11、#160;C.null··  D.空字符串·正確答案:B·11.·(單選)下列賦值語句中,正確的是()。··  A.byte b1 = 10, b2 = 20; byte b=b1+b2;··  B.byte b1 = 10, b2 = 20; byte b=b1;··  C.byte b1 = 10, b2 = 20; byte b=b1>>1;··  D.byte b1 = 10; byte b=+b

12、1;·正確答案:D·12.·(單選)類Super及Sub定義如下: public class Super private void f() System.out.println("Super.f()"); public void g() f(); public void k() f(); public class Sub extends Super private void f() System.out.println("Sub.f()"); public void k() f(); 運行下列語句: Super obj =

13、new Sub(); obj.g(); obj.k(); 輸出的結(jié)果是:()。··  A.Sub.f() Sub.f()··  B.Sub.f() Super.f()··  C.Super.f() Sub.f()··  D.Super.f() Super.f()·正確答案:C·13.·(單選)關(guān)于下列代碼說法正確的是: class ClassA public int numberOfinstances; protected ClassA(int

14、numberOfinstances) this.numberOfinstances = numberOfinstances; public class ExtendedA extends ClassA private ExtendedA(int numberOfinstances) super(numberOfinstances); public static void main(String args) ExtendedA ext = new ExtendedA(420); System.out.print(ext.numberOfinstances); ··  

15、;A.運行后,輸出420··  B.運行時拋出異常··  C.編譯錯誤,所有的構(gòu)造器必須是public的··  D.編譯錯誤,構(gòu)造器不能是private的·正確答案:A·14.·(單選)關(guān)于下列代碼說法正確的是: public class A private int counter = 0; public static int getInstanceCount() return counter; public A() counter+; public static void

16、main(String args) A a1 = new A(); A a2 = new A(); A a3 = new A(); System.out.println(A.getInstanceCount(); ··  A.該類編譯失敗··  B.輸出:1··  C.輸出:3··  D.輸出:0·正確答案:A·15.·(單選)下面for語句,存在編譯錯誤的是()。··  A.for( ; ; )·

17、3;  B.for(int i=0; i < 100;i+)··  C.for(int i = 0, j=0; ;i+,j+)··  D.for(int i = 0; i < 10)·正確答案:D·16.·(單選)請看下列代碼: interface Foo int bar(); public class Sprite public int fubar(Foo foo) return foo.bar(); public void testFoo() fubar( <插入代碼>

18、; ); 使類Sprite編譯通過,在<插入代碼>處應(yīng)填入的代碼是:··  A.Foo public int bar() return 1; ··  B.new Foo public int bar() return 1; ··  C.new Foo() public int bar()return 1; ··  D.new class Foo public int bar() return 1; ·正確答案:C·17.·(單選)請看

19、下列代碼: public class Plant private String name; public Plant(String name) = name; public String getName() return name; class Tree extends Plant public void growFruit() public void dropLeaves() 下列說法正確的是:··  A.在Tree類中添加代碼:public Tree() Plant(); ,編譯將通過··  B.在Plant類

20、中添加代碼:public Plant() Tree(); ,編譯將通過··  C.在Plant類中添加代碼:public Plant() this(”fern”); ,編譯將通過··  D.在Plant類中添加代碼:public Plant() Plant(”fern”); ,編譯將通過·正確答案:C·18.·(單選)請看下列代碼編譯和運行的結(jié)果是()。 interface DeclareStuff public static final int EASY = 3; void doStuff(int t)

21、; public class TestDeclare implements DeclareStuff public static void main(String args) int x = 5; new TestDeclare().doStuff(+x); void doStuff(int s) s += EASY + +s; System.out.println("s=" + s); ··  A.s=14··  B.s=16··  C.s=10··  

22、D.編譯失敗·正確答案:D·19.·(單選)下列關(guān)于IDE開發(fā)環(huán)境Eclipse,說法錯誤的是:()。··  A.Eclipse可以通過插件(plugin)的方式擴展其功能。··  B.Eclipse聯(lián)盟是由IBM公司捐資組建的。··  C.Eclipse使用了SWT圖形界面技術(shù)。··  D.Eclipse的運行不需要有JRE的支持。·正確答案:D·20.·(單選)下列代碼的輸出結(jié)果是: public class B

23、lip protected int blipvert(int x) return 0; class Vert extends Blip <插入代碼> 在<插入代碼>處填入選項中的代碼,使Vert類沒有編譯錯誤的是()。··  A.public int blipvert(int x) return 0; ··  B.private int blipvert(int x) return 0; ··  C.private void blipvert(int x) return 0; &#

24、183;·  D.protected long blipvert(int x) return 0; ·正確答案:A·21.·(單選)下列表達式中,可以得到精確結(jié)果的是()。··  A.double d1 = 3.0 - 2.6;··  B.double d4 = 2.5 * 1.5;··  C.double d2 = 30/300;··  D.double d3 = 1/2 + 0.5;·正確答案:B·22

25、.·(單選)下列代碼的輸出結(jié)果是()。 public static void main(String args) int one=new int4,6,8; int two=new int1,3,5,7,9; System.arraycopy(one, 1, two, 2, 2); System.out.println(Arrays.toString(two); ··  A.1, 3, 7, 4, 6··  B.1, 3, 5, 7, 8··  C.1, 3, 5, 6, 9·

26、3;  D.1, 3, 6, 8, 9·正確答案:D·23.·(單選)下列數(shù)組聲明語句中,錯誤的是:()。··  A.int arr = new int8;··  B.int arr = new int8;··  C.int arr = ;··  D.int arr = new int;·正確答案:B·24.·(單選)下列代碼編譯和運行的結(jié)果是: public static void main(String

27、 args) String elements = "for", "tea", "too" ; String first = (elements.length > 0) ? elements0 : null; System.out.println(first); ··  A.編譯出錯··  B.輸出:tea··  C.輸出:for··  D.輸出:null·正確答案:C·25.·(單

28、選)運行下面的程序: int a = 100; int b = 200; a = a + b; b = a - b; a = a - b; System.out.println("a=" + a + ", b=" + b); 輸出的結(jié)果是:()。··  A.a=100, b=300··  B.a=100, b=200··  C.a=200, b=100··  D.a=300, b=200·正確答案:C·26.

29、3;(單選)下列關(guān)于JVM說法,錯誤的是()。··  A.JVM通過專門的線程實現(xiàn)內(nèi)存的回收。··  B.使用java命令時,可以通過參數(shù)來設(shè)置分配JVM的內(nèi)存大小。··  C.JRE包括JVM及Java核心類庫。··  D.目前主流版本JVM通過純解釋的方式運行Java字節(jié)碼。·正確答案:D·27.·(單選)請看下列代碼: interface Data public void load(); abstract class Info public

30、 abstract void load(); 下列選項中,能正確使用Data接口和Info類的是()。··  A.public class Employee extends Info implements Data public void load() /*do something*/ ··  B.public class Employee implements Info extends Data public void load() /*do something*/ ··  C.public class

31、 Employee implements Info extends Data public void Data.load() /*d something */ public void load() /*do something */ ··  D.public class Employee extends Info implements Data public void load() /*do something */ public void Info.load() /*do something*/ ·正確答案:A·28.·(單選)類A

32、,B的定義如下: class A private int a = 100; A() System.out.print("A()"); System.out.println(a); class B extends A private int a = 200; B() System.out.print("B()"); System.out.println(a); 運行下面的代碼: new B(); 輸出的結(jié)果是:()。··  A.A() 100 B() 200··  B.A() 200 B() 20

33、0··  C.B() 200 A() 100··  D.B() 200 A() 200·正確答案:A·29.·(單選)如下方法聲明中,錯誤的是()。··  A.public void say() System.out.print(“Hi”); ··  B.public void say() System.out.print(“Hi”); return; ··  C.public int say() System.ou

34、t.print(“Hi”); return; ··  D.public int say() System.out.print(“Hi”); return 0; ·正確答案:C·30.·(單選)下列代碼編譯和運行的結(jié)果是()。 public class A public void start() System.out.println("TestA"); public class B extends A public void start() System.out.println("TestB");

35、 public static void main(String args) (A) new B().start(); ··  A.輸出:TestA··  B.輸出:TestB··  C.輸出:TestA TestB··  D.編譯錯誤·正確答案:B·31.·(單選)下列代碼的運行結(jié)果是: public class GoTest public static void main(String args) Sente a = new Sente();

36、a.go(); Goban b = new Goban(); b.go(); Stone c = new Stone(); c.go(); class Sente implements Go public void go() System.out.println("go in Sente"); class Goban extends Sente public void go() System.out.println("go in Goban"); class Stone extends Goban implements Go interface Go p

37、ublic void go(); ··  A.go in Goban go in Sente go in Sente··  B.go in Sente go in Sente go in Goban··  C.go in Sente go in Goban go in Goban··  D.go in Goban go in Goban go in Sente·正確答案:C·32.·(單選)程序的執(zhí)行結(jié)果是()。 public class Tes

38、t int x; public static void main(String args) Test t = new Test(); t.x=5; change(t); System.out.println(t.x); public static void change(Test t) t.x=3; ··  A.5··  B.3··  C.0··  D.4·正確答案:B·33.·(單選)分析如下語句,說法錯誤的是()。·· &

39、#160;A.break可用于跳出循環(huán),當(dāng)多層嵌套時,只用于跳出一層循環(huán)··  B.break即可以出現(xiàn)在循環(huán)語句中也可以出現(xiàn)在switch語句中··  C.continue可以用于跳出循環(huán)··  D.continue不能出現(xiàn)在switch語句中·正確答案:C·34.·(單選)請看下列代碼編譯和運行的結(jié)果是: package packagea; public class Message String getText() return "text" pack

40、age packageb; public class XMLMessage extends packagea.Message String getText() return "<msg>text</msg>" public static void main(String args) System.out.println(new XMLMessage().getText(); ··  A.text··  B.<msg>text</msg>·· 

41、60;C.拋出運行時異常··  D.代碼public class XMLMessage extends packagea.Message行,編譯錯誤·正確答案:B·35.·(單選)程序執(zhí)行的結(jié)果是()。 public class Test String name="Tom" public Test(String name) name=name; public static void main(String args) Test t = new Test("Jack"); System.out.p

42、rintln(); ··  A.null··  B.Tom··  C.Jack··  D." "·正確答案:B·36.·(單選)請看下列代碼的輸出結(jié)果是: public class Bootchy int bootch; String snootch; public Bootchy() this("snootchy"); System.out.print("first ");

43、 public Bootchy(String snootch) this(420, "snootchy"); System.out.print("second "); public Bootchy(int bootch, String snootch) this.bootch = bootch; this.snootch = snootch; System.out.print("third "); public static void main(String args) Bootchy b = new Bootchy(); Syste

44、m.out.print(b.snootch + " " + b.bootch); ··  A.first second third snootchy 420··  B.third second first snootchy 420··  C.third first second snootchy 420··  D.first second first third snootchy 420·正確答案:B·37.·(單選)下列代碼

45、的輸出結(jié)果是:()。 public class StaticFoo int num; static int x; public static void main(String args) StaticFoo foo1 = new StaticFoo (); foo1.num+; foo1.x+; StaticFoo foo2 = new StaticFoo (); foo2.num+; foo2.x+; StaticFoo foo3 = new StaticFoo (); foo3.num+; foo3.x+; StaticFoo.x+; System.out.print(foo3.num+&

46、quot;,"); System.out.println(foo3.x); ··  A.3,3··  B.1,3··  C.3,4··  D.1,4·正確答案:D·38.·(單選)請看下列程序的輸出結(jié)果是: public class Item private String desc; public String getDescription() return desc; public void setDescription(String

47、 d) desc = d; public static void modifyDesc(Item item, String desc) item = new Item(); item.setDescription(desc); public static void main(String args) Item it = new Item(); it.setDescription("Gobstopper"); Item it2 = new Item(); it2.setDescription("Fizzylifting"); modifyDesc(it,

48、"Scrumdiddlyumptious"); System.out.println(it.getDescription(); System.out.println(it2.getDescription(); ··  A.Scrumdiddlyumptious Scrumdiddlyumptious··  B.Scrumdiddlyumptious Fizzylifltng··  C.Gobstopper Scrumdiddlyumptious··  D.

49、Gobstopper Fizzylifting·正確答案:D·39.·(單選)下面的代碼用于對數(shù)組arr實現(xiàn)冒泡排序: for (int i = 0; i < arr.length - 1; i+) boolean isSwap = false; 空白處 if (!isSwap) break; 下列選項中,空白處可以填入的代碼是:()。··  A.for (int j = arr.length - 1; j > i; j-) if (arrj < arrj - 1) int temp = arrj; arrj = a

50、rrj - 1; arrj - 1 = temp; isSwap = true; ··  B.for (int j = arr.length - 1; j > 0; j-) if (arrj < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; ··  C.for (int j = i + 1; j< arr.length; j+) if (arrj < arrj - 1) int temp = arrj; a

51、rrj = arrj - 1; arrj - 1 = temp; isSwap = true; ··  D.for (int j = i; j< arr.length; j+) if (arrj < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; ·正確答案:A·40.·(單選)請看下列代碼: class Payload private int weight; public Payload(int wt) weight

52、= wt; public Payload() public void setWeight(int w) weight = w; public String toString() return Integer.toString(weight); public class TestPayload static void changePayload(Payload p) <插入代碼> public static void main(String args) Payload p = new Payload(); p.setWeight(1024); changePayload(p); Sy

53、stem.out.println("The value of p is " + p); 假設(shè)運行后輸出“The value of p is 420”,那么<插入代碼>處應(yīng)填入代碼是:··  A.p.setWeight(420);··  B.Payload.setWeight(420);··  C.p = new Payload(420);··  D.p = new Payload(); p.setWeight(420);·正確答案:A

54、·41.·(單選)下列代碼的輸出結(jié)果是()。 abstract class Vehicle public int speed() return 0; class Car extends Vehicle public int speed() return 60; class RaceCar extends Car public int speed() return 150; public class TestCar public static void main(String args) RaceCar racer = new RaceCar(); Car car = new

55、 RaceCar(); Vehicle vehicle = new RaceCar(); System.out.println(racer.speed() + ", " + car.speed() + ", " + vehicle.speed(); ··  A.0, 0, 0··  B.150, 60, 0··  C.150, 150, 150··  D.拋出運行時異常·正確答案:C·42.·(單選)題目:

56、 下列代碼的輸出結(jié)果是: ()。 public class A public void info() System.out.println("A info"); public class B extends A public void info() System.out.println("B info"); public static void main(String args) B b=new B(); A a=b; (); ··  A.B info A info··  B.A i

57、nfo B info··  C.A info··  D.B info·正確答案:D·43.·(單選)請看下列代碼: class ClassA class ClassB extends ClassA class ClassC extends ClassA public class Test public static void main(String args) ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new Class

58、C(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); <插入代碼> 可以在<插入代碼>處,填入的代碼正確的是()··  A.p0 = p1;··  B.p1 = p2;··  C.p2 = p4;··  D.p2 = (ClassC)p1;·正確答案:A·44.·(單選)下列代碼的運行結(jié)果是()。 public class Animal public String

59、 noise() return "peep" public static void main(String args) Animal animal = new Dog(); Cat cat = (Cat)animal; System.out.println(cat.noise(); class Dog extends Animal public String noise() return "bark" class Cat extends Animal public String noise() return "meow" ·

60、·  A.peep··  B.bark··  C.meow··  D.拋出運行時異常·正確答案:D·45.·(單選)類A,B和C的定義如下: public class A public void f() System.out.println("A.f()"); public class B extends A public void f() System.out.println("B.f()"); public class C public void g(A a) System.out.println("g(A a)"); a.f(); public void g(B b) System.out.println("g(B b)"); b.f(); 運行下面程序: C c = new C(); A a = new B(); c.g(a); 輸出的結(jié)果是:()。··  A.g(A a) A.f()··  B.g(A a) B

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論