中興JavaWeb開發(fā)工程師筆試題及答案_第1頁
中興JavaWeb開發(fā)工程師筆試題及答案_第2頁
中興JavaWeb開發(fā)工程師筆試題及答案_第3頁
中興JavaWeb開發(fā)工程師筆試題及答案_第4頁
中興JavaWeb開發(fā)工程師筆試題及答案_第5頁
已閱讀5頁,還剩40頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、1中興 Java Web 開發(fā)工程師筆試題及答案如果想保證程序的輸出結(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.列代碼的運行結(jié)果是()。public class Forest impleme nts Serializable private Tree tree = new Tree();public static void main( Stri ng a

2、rgs) 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();2class Tree A. 編譯失敗B. 運行時,拋出異常C. Forest 的實例被序列化到文件D. Forest 的實例和 Tree 的實例都被序列化到文件 正確答

3、案:B6請看下列代碼: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 SortStude nt 3public class TestPayload static void cha ngePayload(Payload p) public sta

4、tic void main( Stri ng args) Payload p = new Payload();p.setWeight(1024);cha ngePayload(p);System.out.pri ntln( 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);正確答案:A7.題目代碼實現(xiàn)的

5、功能是:把放入到 TreeSet 集合中的 Student進(jìn)行排序,首先按照 num 升序,如果 num 相同,再按照 name 降序。請問插入代碼 1和插入代碼 2處應(yīng)填入的代碼分別是:public static void main( Stri ng args) TreeSet set二new TreeSet();stu=(Stude nt)o;4set.add( new Stude nt(19, tom );set.add( new Stude nt(20, jessica );set.add( new Stude nt(19, terry );class Student implemen

6、ts插入代碼 1private int num;private String n ame;public Stude nt(i nt 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)Stude nt stu二nu II;5int result二this .num stu .num 1:(this .num=stu .num 0:-1);if(result

7、=O)result二this. pareTo(stu. name);return result;B. Comparablepublic int compareTo(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 result;C. Compartorpublic int compare(

8、Object o) 6if(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=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 .nu

9、m 1:(this .num=stu .num 0:-1);if(result=0)result=stu. pareTo(this. name);return result;正確答案:B78.下列語句創(chuàng)建對象的總個數(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

10、= d1.subtract(d2);System.out.pri ntl n(d3);A. 0B. 0.1C. 0.100000000000000098D. 0.10正確答案:B10.運行下面程序: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

11、 on e) System.out.pri ntln( con diti on 3 ); fin ally System.out.pri ntl n( fin ally );public static void test() String str = pareTo( abc );9輸出的結(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 cla

12、ss A private int coun ter = 0;public static int get In sta nceCo un t() retur n coun ter;public A() 10coun 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.運行下列代碼發(fā)生的異?;蝈e誤是:pu

13、blic class ClassB public void coun t(i nt i) coun t(+i);public static void main( Stri ng args) ClassB a = new ClassB();a.co un t(3);11A. javaang. StackOverflowErrorB. javaangllegalStateExcepti onC. java.la ng.Exceptio nlnln itializerErrorD. java.la ng.Arrayl ndexOutOfBo un dsExceptio n正確答案:A13.類 A ,

14、 B 的定義如下:class A private int a = 100;A() System.out.pri nt( A();System.out.pri ntl n(a);class B exte nds A private int a = 200;B() System.out.pri nt( B();System.out.pri ntl n(a);運行下面的代碼:12new B();輸出的結(jié)果是:()。A. A() 100B() 200B. A() 200B() 200C. B() 200A() 100D. B() 200A() 200正確答案:A14.下列類的定義,錯誤的是()。A.p

15、ublic class Test exte nds Object .B.final class Operators .C.class Point .D.void class Poi nt 正確答案:D15.13下列代碼的作用說法不正確的是:()。class Card impleme nts java.io.SerializableA.開啟序列化功能,使得 Card 類的對象可以存儲到文件中B.開啟序列化功能,使得 Card 類的對象可以在網(wǎng)絡(luò)上傳輸C.使得 Card 類的子類的對象可以被序列化D.導(dǎo)致 Card 的子類的對象不可以被反序列化正確答案:D16. 程序員需要創(chuàng)建一個泛型類 MinM

16、ax,MinMax 類的屬性 需要實現(xiàn) Comparable 接口,下列選項中的 MinMax 類的實現(xiàn)能編 譯通過的是:A. class MinM ax E min=n ull;E max=n ull;public Mi nM ax() public void put(E value) /* store min or max */ B. class Mi nM ax 14E 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 mi

17、n = n ull;E max = n ull;public Mi nM ax() public void put(E value) /* store min or max */ D. 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 */ 正確答案:A17請看下列代碼:public class Plant private String n ame;public Pla nt(Stri ng n ame) 15this. name =

18、 n ame;public Stri ng getName() return n ame;class Tree exte nds Plant public void growFruit() public void dropLeaves() 下列說法正確的是:A. 在 Tree 類中添加代碼:public Tree() Pla nt(); ,編譯將通過B. 在 Plant 類中添加代碼:public Pla nt() Tree(); ,編譯將通過C. 在 Plant 類中添加代碼:public Pla nt() this( ” fern ”);,編譯將通過D.在 Plant 類中添加代碼:pub

19、lic Plant() Plant( ” fern ”);,編譯將通過正確答案:C18.運行下列代碼:16in t o neArr = 2,11, 26, 27, 37, 44, 48, 60 ;in t twoArr = 19, 35, 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 +

20、q, on eArr.le ngthp) ;else if (qSystem.arraycopy(twoArr, q, threeArr, p + q, twoArr.le ngthq) ;System.out.pri ntl n( Arrays.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

21、,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;17正確答案:B19請看下列代碼:2. public class Test 3. public 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 ar

22、ray1 = str in gs.toArray();D. Iterator i2 = stri ngs.iterator();正確答案:C20.F 列代碼的輸出結(jié)果是()public static void main( Stri ng args) Stri ng test = a1b2c3Strin g toke ns = test.split( d );for (Stri ng s : toke ns)System.out.pri nt(s + );18A.a b cB.1 2 3C.a1b2c3D.al b2 c3正確答案:A21.數(shù)據(jù)類型 int、char 和 double 所占用內(nèi)存

23、字節(jié)數(shù)分別是:()A. 4、B. 2、C. 2、D. 4、正確答案:A1922.如下方法聲明中,錯誤的是()A.23.運行下面的語句:Stri ng s=;if(s=s+0)System.out.pri ntln( Hello World );編譯,運行的結(jié)果是:()。public void say() System.out.pri nt(B.public void say() System.out.pri nt(C.public int say() System.out.pri nt(D.public int say() System.out.pri nt(正確答案:CHi ”);Hi” )

24、; return; Hi” ); return; Hi ”);return20A.Hello WorldB.無輸出C.編譯錯誤D.拋出運行時異常正確答案:B24. List 類的對象 list 中的元素為:0, 1,2, 3, 4, 5, 6, 7, 8, 9,現(xiàn)在想返回該 list 對象的子集合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. 請看下列代碼:in terface Foo int bar();publi

25、c class Sprite public int fubar(Foo foo) 21return foo.bar();public void testFoo() fubar();使類 Sprite 編譯通過,在處應(yīng)填入的代碼是:A. Foo public int bar() 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.需要讀取一個比較大的文本文件, 這個

26、文件里有很多字節(jié)的 數(shù)據(jù),那么下列最合適讀這個文件的選項是:()。A.new FileInputStream(“fileName ” );B.newIn putStreamReader( newFileInputStream( “fileName ” );C.22new BufferedReader( newIn putStreamReader( newFileInputStream( “fileName ” );D.new RandomAccessFile( “fileName ” : +rw ” );正確答案:C27. 下列不屬于 Collection 接口的方法的是:A. clearB.

27、 containsC. removeD. listIterator正確答案:D28. 下列代碼運行的結(jié)果是:public static void main( Stri ng args) List list = new ArrayList();list.add( b );list.add( a );list.add( c );System.out.pri ntl n( Collectio ns.bi narySearch(list, a );A. 0B. 1C. a23D. b正確答案:B29. 下列選項中,不能包含重復(fù)元素的容器是:()A.ListB.ArrayListC.SetD.Colle

28、ctio n正確答案:C30. 下面關(guān)于 in terface,敘述錯誤的是:()A.一個 in terface 可以繼承多個 in terfaceB.接口中的方法可以由 private 修飾C.in terface 中可以定義 static final 常量D.in terface 中可以無任何方法定義正確答案:B2431. 下面關(guān)于 final 說法正確的是:()。A.final 修飾類時,該類能被繼承。B.final 修飾方法時,該方法能被重寫。C.當(dāng)使用 static final 修飾的常量時,將采用編譯期綁定的方式。D.當(dāng)使用 final 和 abstract 共同修飾一個類時,fi

29、nal 應(yīng)至于 abstract 之前。正確答案:C32. 下列不屬于 Java 運算符的是()。A. B. C.D.33. 下面不屬于 Java 語言特點的是:A.平臺無關(guān)B. 面向?qū)ο?5C. 支持指針類型D. 垃圾回收機制正確答案:C34. 請看下列代碼:public in terface A Stri ng DEFAULT_GREETING = Hello Worldpublic void method1();現(xiàn)有接口 B,是 A 接口的子接口,下列選擇中 B 接口的聲明正 確的是:A. public in terface B exte nds A B. public in terfa

30、ce 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 ,default , protected , privateB. private 可以用于外部類的聲明C. 一個 Java 源文件中聲明為 public 的外部類只能有一個26D. protected 聲明的方法不可以被子類重寫正確答案:C36. 請看下列代碼:Map

31、map二new HashMap();map.put( one ,100);map.put( two ,200);map.put( three ,300);Set set = new HashSet();27遍歷 map 對象中的每一個元素,下列選項正確的是:A. Set set二map.keySet();for(Stri ng key:set)In teger value二map.get(key);System.out.println(key+”:” +value);B. List list二map.keyList();for(Stri ng key:list)In teger value二m

32、ap.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 per:list)System.out.pri ntln (per.getKey() + : + per.getValue();正確答案:AC37.關(guān)于下列代碼說法正確的是:C. C c1 = (

33、C) new A();28Ran 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. 代碼將隨機產(chǎn)生 10 個 100 以內(nèi)的可重復(fù)的整數(shù),并將其放 入集合中。C. 代碼循環(huán)執(zhí)行的次數(shù)可能會大于 10 次,重復(fù)的整數(shù)無法放入 set集合中。D. 代碼將隨機產(chǎn)生元素個數(shù)為 10 個的 100 以內(nèi)不重復(fù)整數(shù)集 合。正確答案:CD38.類 A、B 及接口 C 的定義如下:class A fin al class

34、 B in terface C 下列語句有編譯錯誤的是:()A. A a = (A)new Object();B. B b = (B) new A();Thread t = new Runn er();29D. 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 er();Thread t = new Thread(r); t

35、.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();41.30D. class Runner public static void mai n( Stri ng

36、args)Thread t = new Thread()public void run() 線程體;t.start();正確答案:ACD40.請看下列代碼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,Stri ng s)D. public int me

37、thod(i nt year,Stri ng s)正確答案:CDScoreMa nager類實現(xiàn)了成績管理系統(tǒng)。該系統(tǒng)有如下功能供選則:錄入成績,成績列表,查詢成績,退出。當(dāng)用戶在控制臺輸 入 1,用戶選擇的功能為錄入成績;輸入 2,用戶選擇的功能為成績 列表;輸入313,用戶選擇的功能為根據(jù)姓名查找成績;輸入 4,退出。ScoreMa nager 類代碼如下:public class ScoreMa nager public static void main( Stri ng args) int numOfStude nts = 10;/學(xué)生名字信息數(shù)組Stri ngstude nts=Na

38、meUtils.ra ndomNames (num OfStude nts);int scores = new in t num OfStude nts;/學(xué)生成績數(shù)組/使用 Scanner 接收控制臺的輸入信息空白處 1System.out.pri ntln(* 歡迎進(jìn)入成績管理系統(tǒng)* );while (true) System.out.pri ntl n(請選擇功能:1成績錄入,2成績列表,3 成績查詢,4退出);Stri ng c = sca nner.n ext().trim();if ( 1 .equals(c) System.out.pri ntl n(開始錄入成績: );32fo

39、r (int i = 0; iSystem.out.pri nt(i + 1) + .學(xué)生姓名: + stude ntsi+ ,成績:);/從控制臺接收到學(xué)生成績空白處 2System.out.pri ntln(錄入完畢。); else if ( 2 .equals(c) int avg = 0;for (int i = 0; iavg += scoresi;/計算學(xué)生的評價成績空白處 3System.out.println(StringUtils.rightPad(編號,20,)+ Str in gUtils.rightPad( 姓名,20,)+ Str in gUtils.rightPad

40、( 成績,20,);System.out.pri ntln (Stri ngUtils.repeat( - , 30);for (int i = 0; iSystem.out.pri ntl n( Stri ngUtils.rightPad(i + 1 + , 10,)33+ Str in gUtils.rightPad(stude ntsi, 10,)+ Str in gUtils.rightPad(scoresi + , 10,);System.out.pri ntln (Stri ngUtils.repeat( - , 30);System.out.println(平均成績:+ avg)

41、; else if ( 3 .equals(c) System.out.pri nt(請輸入您要查詢的學(xué)生姓名:);Stri ng stude nt = sca nner.n ext().trim();int i = 0;for (; i/如果查找到某個學(xué)生的信息,退出當(dāng)前循環(huán)空白處 4if (空白處 5 ) System.out.pri ntln(i + 1) + . 學(xué)生姓名:+ stude ntsi+ ,成績:+ scoresi); else System.out.pri ntln(對不起,找不到學(xué)員的信息。); else if ( 4 .equals(c) System.out.pri

42、ntln( *謝謝使用 * );break;34sea nn er.close();(1) .下列選項中,能填入空白處 1 的代碼是()A.Scanner sea nner = new Sea nn er(System.out);B.Scanner sea nner = new Sea nn er(System.i n);C.Scannerseanner= newFilel nputStream(System.i n);D.Scannerseanner= newFileOutputStream(System.out);正確答案:B(2) .下列選項中,能填入空白處 2 的代碼是()A.seor

43、esi = sea nner.n ext In t();B.seoresi = sea nner.n ext();Scanner(newScanner(new35C.scoresi = sea nner.n extDouble();D.scoresi = sea nner.n extStri ng();正確答案:A(3) .下列選項中,能填入空白處 3 的代碼是()A.avg *= scoresen gth;B.avg /= scoresen gth;C.avg *= scoresen gth-1;D.avg /= scoresen gth-1;正確答案:B(4) .下列選項中,能填入空白處

44、4 的代碼是()A.if (stude nt.equalslg noreCase(stude ntsi-1) break;B.36if (stude nt.equalslg noreCase(stude ntsi) 42.37con 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).下列選項中,能填入空白處 5 的代碼是()A.scoresengthB.scoresengthC.iD.i正確答案:C歌德巴赫猜想的近似證明38歌德巴赫猜想是說任何一個大于 2 的偶數(shù)都能表示為兩個素數(shù) 之和,請編寫一個 Java 程序,驗證 1100 內(nèi)歌德巴赫猜想的正確

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論