




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、中興Java開發(fā)筆試題 JSD1304如果想保證程序的輸出結(jié)果是1,2,那么處應(yīng)填入的代碼是()A. Set set = new TreeSet();B. Set set = new HashSet();C. Set set = new SortedSet();D. Set set = new Li nkedHashSet();正確答案:A5.列代碼的運(yùn)行結(jié)果是()。public class Forest impleme nts Serializable private Tree tree = new Tree();public static void main( Stri ng args)
2、Forest f = new Forest();try FileOutputStream fs = new FileOutputStream( Forest.ser );ObjectOutputStream os = new ObjectOutputStream(fs);os.writeObject(f);os.close(); catch (Excepti on ex) ex.pri ntStackTrace();class Tree A. 編譯失敗B. 運(yùn)行時(shí),拋出異常C. Forest的實(shí)例被序列化到文件D. Forest的實(shí)例和Tree的實(shí)例都被序列化到文件 正確答案:B6請(qǐng)看下列代碼
3、:class Payload private int weight;public Payload(i nt wt) weight = wt;public Payload() public void setWeight(i nt w) weight = w;public Stri ng toStri ng() retur n In teger.toStri ng(weight);public class TestPayload static void cha ngePayload(Payload p) public static void main( Stri ng args) Payload
4、p = new Payload();p.setWeight(1024);cha ngePayload(p);System.out.pri ntln( The value of p is + p);假設(shè)運(yùn)行后輸出“ 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);正確答案:A7.題目代碼實(shí)現(xiàn)的功能是:把放入到TreeSet集合中的Student進(jìn)行排序,首先按照nu
5、m升序,如果num相同,再按照name降序。請(qǐng)問插入代碼1和插入代碼2處應(yīng)填入的代碼分別是:public static void main( Stri ng args) TreeSet set 二new TreeSet();set.add( new Stude nt(19, tom );set.add( new Stude nt(20, jessica );set.add( new Stude nt(19, terry );class Student implements插入代碼 1private int num;private String n ame;public Stude nt(i n
6、t nu m,Stri ng n ame)this .n ame=n ame;this .num二num;插入代碼2A. Comparablepublic int compareTo(Object o) Stude nt stu 二nu II;if(o in sta nceof Stude nt)int result二this .num stu .num 1:(this .num=stu .num 0:-1); if(result=O)result二this. pareTo(stu. name);return result;B. Comparablepublic int compareTo(O
7、bject o) Stude nt stu 二nu II;if(o in sta nceof Stude nt)stu=(Stude nt)o;int result=this .num stu .num 1:(this .num=stu .num 0:-1);if(result=0)result=stu. pareTo(this. name);return result;C. Compartorpublic int compare(Object o) if(o in sta nceof Stude nt)stu=(Stude nt)o;int result二this .num stu .num
8、 1:(this .num=stu .num 0:-1);if(result=O)result二this. pareTo(stu. name);return result;D. Compartorpublic int compare(Object o) Stude nt stu 二nu II;if(o in sta nceof Stude nt)stu=(Stude nt)o;int result=this .num stu .num 1:(this .num=stu .num 0:-1);if(result=0)result=stu. pareTo(this. name);return re
9、sult;正確答案:B8.下列語句創(chuàng)建對(duì)象的總個(gè)數(shù)是:()。Stri ng s=a + b + c + d + eA.1B.2C.3D.4正確答案:A9.下列代碼的輸出結(jié)果是:public static void main( Stri ng args) BigDecimal d1 = new BigDecimal( 3.0 );BigDecimal d2 = new BigDecimal( 2.9 );BigDecimal d3 = d1.subtract(d2);System.out.pri ntl n(d3);A. 0B. 0.1C. 0.10000000000000009D. 0.10正
10、確答案:B10.運(yùn)行下面程序:public class Foopublic static void main( Stri ng args) try test();System.out.pri ntln( con diti on 1 ); catch (ArrayI ndexOutOfBo un dsExceptio n e) System.out.pri ntln( con diti on 2 ); catch (Excepti on e) System.out.pri ntln( con diti on 3 ); fin ally System.out.pri ntl n( fin ally
11、 );public static void test() String str = ccpareTo( abc );輸出的結(jié)果是:()A.con diti on 1fin allyB.con diti on 2fin allyC.con diti on 1con diti on 3fin allyD.con diti on 1con diti on 2fin ally正確答案:A11. 關(guān)于下列代碼說法正確的是:public class A private int coun ter = 0;public static int get In sta nceCo un t() retur n co
12、un ter;public A() coun ter+;public static void main( Stri ng args) A a1 = new A();A a2 = new A();A a3 = new A();System.out.pri ntl n( A.getI nsta nceCo un t();A. 該類編譯失敗B. 輸出:1C. 輸出:3D. 輸出:0正確答案:A12. 運(yùn)行下列代碼發(fā)生的異?;蝈e(cuò)誤是:public class ClassB public void coun t(i nt i) coun t(+i);public static void main( St
13、ri ng args) ClassB a = new ClassB();a.co un t(3);A. javaang. StackOverflowErrorB. javaangllegalStateExcepti onC. java.la ng.Exceptio nlnln itializerErrorD. java.la ng.Arrayl ndexOutOfBo un dsExceptio n正確答案:A13.類A , B的定義如下:class A private int a = 100;A() System.out.pri nt( A();System.out.pri ntl n(a)
14、;class B exte nds A private int a = 200;B() System.out.pri nt( B();System.out.pri ntl n(a);運(yùn)行下面的代碼:new B();輸出的結(jié)果是:()。A. A() 100B() 200B. A() 200B() 200C. B() 200A() 100D. B() 200A() 200正確答案:A14.下列類的定義,錯(cuò)誤的是()。A.public class Test exte nds Object B.final class Operators C.class Point D.void class Poi n
15、t 正確答案:D15.下列代碼的作用說法不正確的是:()。class Card impleme nts java.io.SerializableA.開啟序列化功能,使得Card類的對(duì)象可以存儲(chǔ)到文件中B.開啟序列化功能,使得 Card類的對(duì)象可以在網(wǎng)絡(luò)上傳輸C.使得Card類的子類的對(duì)象可以被序列化D.導(dǎo)致Card的子類的對(duì)象不可以被反序列化正確答案:D16. 程序員需要?jiǎng)?chuàng)建一個(gè)泛型類 MinMax,MinMax 類的屬性 需要實(shí)現(xiàn)Comparable接口,下列選項(xiàng)中的MinMax類的實(shí)現(xiàn)能編 譯通過的是:A. class MinM ax E min=n ull;E max=n ull;pub
16、lic Mi nM ax() public void put(E value) /* store min or max */ B. class Mi nM ax E min=n ull;E max=n ull;public Mi nM ax() public void put(E value) /* store min or max */ C. class Mi nM ax E min = n ull;E max = n ull;public Mi nM ax() public void put(E value) /* store min or max */ D. class Mi nM ax
17、 E min = n ull;E max = n ull;public Mi nM ax() public void put(E value) /* store min or max */ 正確答案:A17請(qǐng)看下列代碼:public class Plant private String n ame;public Pla nt(Stri ng n ame) this. name = n ame;public Stri ng getName() return n ame;class Tree exte nds Plant public void growFruit() public void dr
18、opLeaves() 下列說法正確的是:A.在Tree類中添加代碼:public Tree() Pla nt(); ,編譯將通過B.在Plant類中添加代碼:public Pla nt() Tree(); ,編譯將通過C.在Plant類中添加代碼:public Pla nt() this( ”fern ”); ,編譯將通過D.在 Plant 類中添加代碼:public Plant() Plant( ” fern ”); ,編譯將通過正確答案:C18.運(yùn)行下列代碼:in t o neArr = 2,11, 26, 27, 37, 44, 48, 60 ;in t twoArr = 19, 35,
19、 49, 55, 58, 75, 83, 84, 91,93 ;in t threeArr = new in t on eArr.le ngth + twoArr.le ngth;int p = 0, q = 0;while (pthreeArr =on eArrif (pSystem.arraycopy (on eArr, p, threeArr, p + q, on eArr.le ngthp);else if (qSystem.arraycopy(twoArr, q, threeArr, p + q, twoArr.le ngthq);System.out.pri ntl n( Arra
20、ys.toStri ng(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,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;正確答案:B19請(qǐng)看下列代碼:2. public class Test 3. publ
21、ic static void main( Stri ng args) 4. List stri ngs = new ArrayList();5.5. 6. 下列選擇中放在第5行編譯失敗的是:A. String s = stri ngs.get(0);B. Iterator i1 = stri ngs.iterator();C. Strin g array1 = str in gs.toArray();D. Iterator i2 = stri ngs.iterator();正確答案:C20.F列代碼的輸出結(jié)果是()public static void main( Stri ng args) S
22、tri ng test = a1b2c3Strin g toke ns = test.split( d );for (Stri ng s : toke ns)System.out.pri nt(s + );A.a b cB.1 2 3C.a1b2c3D.al b2 c3正確答案:A21.數(shù)據(jù)類型int、char和double所占用內(nèi)存字節(jié)數(shù)分別是:()A. 4、B. 2、C. 2、D. 4、正確答案:A22.如下方法聲明中,錯(cuò)誤的是()A.public void say() System.out.pri nt(B.public void say() System.out.pri nt(C.pu
23、blic int say() System.out.pri nt(D.public int say() System.out.pri nt(正確答案:CHi ”); Hi” ); return; Hi” ); return; Hi ”); return 0; 23.運(yùn)行下面的語句:Stri ng s=;if(s=s+0)System.out.pri ntln( Hello World );編譯,運(yùn)行的結(jié)果是:()。A.Hello WorldB.無輸出C.編譯錯(cuò)誤D.拋出運(yùn)行時(shí)異常正確答案:B24. List 類的對(duì)象 list 中的元素為:0, 1,2, 3, 4, 5, 6, 7, 8, 9
24、,現(xiàn)在想返回該list對(duì)象的子集合5,6,7,8,需要做的操作是:A. list.subList(5, 8);B. list.subList(5, 9);C. list.subList(4, 8);D. list.subList(4, 9);正確答案:B25. 請(qǐng)看下列代碼:in terface Foo int bar();public class Sprite public int fubar(Foo foo) return foo.bar();public void testFoo() fubar();使類Sprite編譯通過,在處應(yīng)填入的代碼是:A. Foo public int bar
25、() return 1; B. new Foo public int bar() retur n 1; C. new Foo() public int bar()retur n 1; D. new class Foo public int bar() retur n 1; 正確答案:C26.需要讀取一個(gè)比較大的文本文件,這個(gè)文件里有很多字節(jié)的 數(shù)據(jù),那么下列最合適讀這個(gè)文件的選項(xiàng)是:()。A.new FileInputStream(“fileName ” );B.newIn putStreamReader( newFileInputStream( “fileName ” );C.new Buf
26、feredReader( newIn putStreamReader( newFileInputStream( “fileName ” );D.new RandomAccessFile( “fileName ” : +rw ” );正確答案:C27. 下列不屬于Collection 接口的方法的是:A. clearB. containsC. removeD. listIterator正確答案:D28. 下列代碼運(yùn)行的結(jié)果是:public static void main( Stri ng args) List list = new ArrayList();list.add( b );list.
27、add( a );list.add( c );System.out.pri ntl n( Collectio ns.bi narySearch(list, a );A. 0B. 1C. aD. b正確答案:B29. 下列選項(xiàng)中,不能包含重復(fù)元素的容器是:()A.ListB.ArrayListC.SetD.Collectio n正確答案:C30. 下面關(guān)于in terface,敘述錯(cuò)誤的是:()A.一個(gè)in terface 可以繼承多個(gè)in terfaceB.接口中的方法可以由private修飾C.in terface 中可以定義static final 常量D.in terface中可以無任何
28、方法定義正確答案:B31. 下面關(guān)于final說法正確的是:()。A.final修飾類時(shí),該類能被繼承。B.final修飾方法時(shí),該方法能被重寫。C.當(dāng)使用static final修飾的常量時(shí),將采用編譯期綁定的方式。D.當(dāng)使用final和abstract 共同修飾一個(gè)類時(shí),final應(yīng)至于 abstract 之前。正確答案:C32. 下列不屬于Java運(yùn)算符的是()。A. B. C.D.33. 下面不屬于Java語言特點(diǎn)的是:A. 平臺(tái)無關(guān)B. 面向?qū)ο驝. 支持指針類型D. 垃圾回收機(jī)制正確答案:C34. 請(qǐng)看下列代碼:public in terface A Stri ng DEFAULT
29、_GREETING = Hello Worldpublic void method1();現(xiàn)有接口 B,是A接口的子接口,下列選擇中 B接口的聲明正 確的是:A. public in terface B exte nds A B. public in terface B impleme nts A C. public in terface B in sta nceOf A D. public in terface B in heritsFrom A 正確答案:A35. 在Java語言中,下列說法正確的是:()。A. Java訪問修飾符按照訪問范圍由低到高的排列 順序是public ,defau
30、lt , protected , privateB. private可以用于外部類的聲明C. 一個(gè)Java源文件中聲明為public的外部類只能有一個(gè)D. protected 聲明的方法不可以被子類重寫正確答案:C36. 請(qǐng)看下列代碼:Map map二new HashMap();map.put( one ,100);map.put( two ,200);map.put( three ,300);遍歷map對(duì)象中的每一個(gè)元素,下列選項(xiàng)正確的是:A. Set set二map.keySet();for(Stri ng key:set)In teger value二map.get(key);Syste
31、m.out.println(key+” :” +value);B. List list二map.keyList();for(Stri ng key:list)In teger value二map.getKey(key);System.out.println(key+” :” +value);C. Set set = map.e ntrySet();for (Map.E ntry per : set) System.out.pri ntln (per.getKey() + : + per.getValue();D. List list=map.e ntryList();for(E ntry pe
32、r:list)System.out.pri ntln (per.getKey() + : + per.getValue();正確答案:AC37. 關(guān)于下列代碼說法正確的是:Ran dom r = new Ran dom();int i = 0;while (set.size()set.add(r .n extl nt(1OO); i+;A. 代碼循環(huán)執(zhí)行的次數(shù)一定為10次,重復(fù)的整數(shù)可以放入set 集合中。B. 代碼將隨機(jī)產(chǎn)生10個(gè)100以內(nèi)的可重復(fù)的整數(shù),并將其放 入集合中。C. 代碼循環(huán)執(zhí)行的次數(shù)可能會(huì)大于10次,重復(fù)的整數(shù)無法放入 set集合中。D. 代碼將隨機(jī)產(chǎn)生元素個(gè)數(shù)為10個(gè)的10
33、0以內(nèi)不重復(fù)整數(shù)集 合。正確答案:CD38. 類A、B及接口 C的定義如下:class A fin al class B in terface C 下列語句有編譯錯(cuò)誤的是:()A. A a = (A)new Object();B. B b = (B) new A();D. C c2 = (C) new B();正確答案:BD39. 以下創(chuàng)建線程的方式正確的是:A. class Runner impleme nts Runn able public void run() 線程體public static void mai n( Stri ng args) Runner r = new Runn
34、er();Thread t = new Thread(r); t.start();B. class Runner impleme nts Runn able public void run() 線程體public static void mai n( Stri ng args) Runner t = new Runn er();t.start();C. class Runner exte nds Thread public void run() 線程體public static void mai n( Stri ng args)t.start();D. class Runner public
35、static void mai n( Stri ng args)Thread t = new Thread()public void run() 線程體;t.start();正確答案:ACD40. 請(qǐng)看下列代碼public class Foo public void method(Stri ng str,i nt age)和Foo類中method方法重載的方法是A. public int method(Stri ng str,i nt age)B. public void method(Stri ng s,i nt year)C. public void method(i nt year,St
36、ri ng s)D. public int method(i nt year,Stri ng s)正確答案:CDScoreMa nager類實(shí)現(xiàn)了成績管理系統(tǒng)。該系統(tǒng)有如下功能供選則:錄入成績,成績列表,查詢成績,退出。當(dāng)用戶在控制臺(tái)輸 入1,用戶選擇的功能為錄入成績;輸入 2,用戶選擇的功能為成績 列表;輸入3,用戶選擇的功能為根據(jù)姓名查找成績;輸入4,退出。ScoreMa nager 類代碼如下:public class ScoreMa nager public static void main( Stri ng args) int numOfStude nts = 10;/學(xué)生名字信息數(shù)
37、組Stri ngstude nts=NameUtils.ra ndomNames (num OfStude nts);int scores = new in t num OfStude nts;/學(xué)生成績數(shù)組/使用Scanner接收控制臺(tái)的輸入信息空白處1System.out.pri ntln(* 歡迎進(jìn)入成績管理系統(tǒng)* );while (true) System.out.pri ntl n(請(qǐng)選擇功能:1成績錄入,2成績列表,3 成績查詢,4退出);Stri ng c = sca nner.n ext().trim();if ( 1 .equals(c) System.out.pri ntl
38、 n(開始錄入成績: );for (int i = 0; iSystem.out.pri nt(i + 1) + .學(xué)生姓名:+ stude ntsi+ ,成績:);/從控制臺(tái)接收到學(xué)生成績空白處2System.out.pri ntln(錄入完畢。); else if ( 2 .equals(c) int avg = 0;for (int i = 0; iavg += scoresi;/計(jì)算學(xué)生的評(píng)價(jià)成績空白處3System.out.println(StringUtils.rightPad(編號(hào),20,)+ Str in gUtils.rightPad( 姓名,20,)+ Str in gUt
39、ils.rightPad( 成績,20,);System.out.pri ntln (Stri ngUtils.repeat( - , 30);for (int i = 0; iSystem.out.pri ntl n( Stri ngUtils.rightPad(i + 1 + , 10,)+ Str in gUtils.rightPad(stude ntsi, 10,)+ Str in gUtils.rightPad(scoresi + , 10,);System.out.pri ntln (Stri ngUtils.repeat( - , 30);System.out.println(平
40、均成績:+ avg); else if ( 3 .equals(c) System.out.pri nt(請(qǐng)輸入您要查詢的學(xué)生姓名:);Stri ng stude nt = sca nner.n ext().trim();int i = 0;for (; i/如果查找到某個(gè)學(xué)生的信息,退出當(dāng)前循環(huán)空白處4if (空白處5 ) System.out.pri ntln(i + 1) + . 學(xué)生姓名:+ stude ntsi+ ,成績:+ scoresi); else System.out.pri ntln(對(duì)不起,找不到學(xué)員的信息。); else if ( 4 .equals(c) System
41、.out.println( *謝謝使用 * );break;sea nn er.close();(1) .下列選項(xiàng)中,能填入空白處1的代碼是()A.Scanner sea nner = new Sea nn er(System.out);B.Scanner sea nner = new Sea nn er(System.i n);C.Scanner(newScanner(newScannerseanner= newFilel nputStream(System.i n);D.Scannerseanner= newFileOutputStream(System.out);正確答案:B(2) .下
42、列選項(xiàng)中,能填入空白處2的代碼是()A.seoresi = sea nner.n ext In t();B.seoresi = sea nner.n ext();C.scoresi = sea nner.n extDouble();D.scoresi = sea nner.n extStri ng();正確答案:A(3) .下列選項(xiàng)中,能填入空白處3的代碼是()A.avg *= scoresen gth;B.avg /= scoresen gth;C.avg *= scoresen gth-1;D.avg /= scoresen gth-1;正確答案:B(4) .下列選項(xiàng)中,能填入空白處 4的
43、代碼是()A.if (stude nt.equalslg noreCase(stude ntsi-1) break;B.if (stude nt.equalslg noreCase(stude ntsi) con ti nue;C.if (stude nt.equalslg noreCase(stude ntsi-1) con ti nue;D.if (stude nt.equalslg noreCase(stude ntsi) break;正確答案:D(5).下列選項(xiàng)中,能填入空白處 5的代碼是()A.scoresengthB.scoresengthC.iD.i正確答案:C歌德巴赫猜想的近似證明歌德巴赫猜想是說任何一個(gè)大于 2的偶數(shù)都能表示為兩個(gè)素?cái)?shù) 之和,請(qǐng)編寫一個(gè)Ja
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 客戶經(jīng)理年終個(gè)人工作總結(jié)模版
- 社區(qū)護(hù)理資源配置優(yōu)化策略
- 快速充電技術(shù)的探索
- 風(fēng)險(xiǎn)管理套期保值講解
- 火電廠生產(chǎn)工藝流程
- 養(yǎng)老護(hù)理標(biāo)準(zhǔn)化流程
- 余姚四中教師考試試題及答案
- 有關(guān)古代法律的考試題及答案
- 銀行行長面試題目及答案
- 老人晨起護(hù)理
- 放射性物品道路運(yùn)輸申請(qǐng)表樣表
- 110kV變電站高壓試驗(yàn)報(bào)告完整版
- 山東大學(xué)《概率論與數(shù)理統(tǒng)計(jì)》期末試題及答案
- TSG Z7001-2004 特種設(shè)備檢驗(yàn)檢測機(jī)構(gòu)核準(zhǔn)規(guī)則
- 入學(xué)、幼兒園等健康衛(wèi)生教育洗手知識(shí)教育ppt課件
- JJF(鄂) 82-2021 全自動(dòng)混凝土抗?jié)B儀校準(zhǔn)規(guī)范(高清版)
- 流動(dòng)注射分析儀常見問題解決方案.
- 材料科學(xué)基礎(chǔ)基礎(chǔ)知識(shí)點(diǎn)總結(jié)
- 數(shù)控銑工圖紙(60份)(共60頁)
- 新時(shí)達(dá)-奧莎(sigriner)iAStar-S32電梯專用變頻器使用說明書
- 《青年友誼圓舞曲》教案
評(píng)論
0/150
提交評(píng)論