


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、在線考試 本次考試得分: 100.0溫馨提示:第七題BC答案都正確1.(單選)下列屬于不合法Java標(biāo)識(shí)符的是()。A. _memB. 12aC. M12D. $12正確答案: B2.(單選)程序的執(zhí)行結(jié)果是:public class Test public static voidmain(String args) System.out.println(""+'a'+1); A. 98B. a1C. 971D. 197正確答案: B3.(單選)下列Java標(biāo)識(shí)符,錯(cuò)誤的是()A. _sys_varlB. $changeC. User_nameD. 1_fil
2、e 正確答案: D 4.(單選)請(qǐng)看下列代碼: public String makinStrings() String s = "Fred" s = s + "47" s = s.substring(2, 5); s = s.toUpperCase(); return s.toString(); 調(diào)用 makinString 方法,得到的字符串長(zhǎng)度是:A. 1B. 2C. 3D. 4正確答案: C5.(單選)分析如下代碼,輸出結(jié)果為()。public static voidmain(String args) int i = 0; boolean re =
3、 false; re = (+i) + i = 2) ? true : false; System.out.println("i=" + i + ",re="+re); A. i=1,re=trueB. i=0,re=trueC. i=1,re=falseD. i=0,re=false正確答案: A6.(單選)下列代碼的運(yùn)行結(jié)果是() public static void main(String args) String str = "420" str += 42; System.out.print(str); A. 42B. 420
4、C. 462D. 42042正確答案: D7.(單選)請(qǐng)看下列代碼: public static void main(String args) 插入 代碼 System.out.println(s); 如果程序輸出的結(jié)果是 4247,那么 在 插入代碼 處應(yīng)該填入代碼是()。A. String s = "123456789" s = (s-"123").replace(1,3,"24") - "89"B. StringBuffer s = new StringBuffer("123456789"
5、);s.delete(0,3).replace( 1,3, "24").delete(4,6);C. StringBuffer s = new StringBuffer("123456789"); s.delete(0,3).replace( 1,3, "24").delete(4,6);D. StringBuilder s = new StringBuilder("123456789");s.substring(3,6).delete( 1 ,2).insert( 1, "24");正確答案:
6、 B8.(單選)下列關(guān)于IDE開發(fā)環(huán)境Eclipse,說法錯(cuò)誤的是:()。A. Eclipse可以通過插件(plugin)的方式擴(kuò)展其功能。B. Eclipse聯(lián)盟是由IBM公司捐資組建的。C. Eclipse使用了 SWT圖形界面技術(shù)。D. Eclipse的運(yùn)行不需要有JRE的支持。正確答案: D9.(單選)下列賦值語(yǔ)句中,正確的是() 。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
7、b1 = 10; byte b=+b1;正確答案: D10.(單選)運(yùn)行下面的語(yǔ)句 : String s=""if(s=s+0) System.out.println("Hello World"); 編譯,運(yùn)行的結(jié)果 是:()。A. Hello WorldB. 無(wú)輸出C編譯錯(cuò)誤D.拋出運(yùn)行時(shí)異常 正確答案: B11. (單選)下列代碼編譯和運(yùn)行的結(jié)果是:public static void main(String args) String elements = "for", "tea", "too&quo
8、t; ; Stringfirst = (elements.length > 0) ? elements0 : null; System.out.println(first); A. 編譯出錯(cuò)B輸出:teaC輸出:forD.輸出:null正確答案: C12.(單選 )下列表達(dá)式中,可以得到精確結(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;正確答案: B13.(單選 )下列關(guān)于 JVM 說法,錯(cuò)誤的是()。JVM 的內(nèi)存大小。Java
9、字節(jié)碼。A. JVM 通過專門的線程實(shí)現(xiàn)內(nèi)存的回收。B. 使用java命令時(shí),可以通過參數(shù)來(lái)設(shè)置分配C. JRE包括 JVM及Java核心類庫(kù)。D. 目前主流版本JVM通過純解釋的方式運(yùn)行正確答案: D 14.(單選)請(qǐng)看下列代碼: interface Data public void load(); abstract class Info public abstract void load(); 下列選項(xiàng)中,能正確使用 Data 接口和 Info 類的是()。A. public class Employee extends Info implements Data public void l
10、oad() /*do something*/ B. public class Employee implements Info extends Data public void load() /*do something*/ C. public class Employee implements Info extends Data public void Data.load() /*d something */ public void load() /*do something */ D. public class Employee extends Info implements Data p
11、ublic void load() /*do something */ public void Info.load() /*do something*/ 正確答案: A15.(單選)下列數(shù)組聲明語(yǔ)句中,錯(cuò)誤的是:()。A. int arr = new int8;B. int arr = new int8;C. int arr = ;D. int arr = new int; 正確答案: B 16. (單選)運(yùn)行下列代碼: int oneArr = 2, 11, 26, 27, 37, 44, 48, 60 ; int twoArr = 19, 35, 49, 55, 58, 75, 83, 8
12、4, 91, 93 ; int threeArr = 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
13、if (q < twoArr.length) System.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,58,75,83,84,91,93,2,11,26
14、,27,37,44,48,60;D. 2,19,11,35,26,49,27,55,37,58,44,75,48,83,60,84,91,93; 正確答案: B17.(單選)程序的執(zhí)行結(jié)果是: public class Test public static void main(String args) String str1 = new String("abc"); String str2 = new String("abc"); String str3 = str1;if(str1.equals(str2) System.out.println(&qu
15、ot;true"); else System.out.pr intln("false"); if(str1=str3) System.out.println("true"); else System.out.println(" false"); A. true trueB. true falseC. false trueD. false false正確答案: A18.(單選)運(yùn)行下面的程序: String fileNames = "abc.txt", "bcd.exe", "
16、cde.exe", "def.dat","efg.exe" ; for (String fileName : fileNames) if (fileName.endsWith(".exe") System.out.print(fileName.substring(0,fileName .lastIndexOf(".exe")+" "); 控制臺(tái)的輸出結(jié)果是: ()A. bcd. cde. efg.B. bc cd efC. bcd.exe cde.exe efg.exeD. bcd c
17、de efg正確答案: D19.(單選)如下方法聲明中,錯(cuò)誤的是()。A. public void say() System.out.print(“Hi” ); B. public void say() System.out.print(“Hi” ); return; C. public int say() System.out.print(“Hi” ); return; D. public int say() System.out.print(“Hi” ); return 0; 正確答案: C 20.(單選)數(shù)據(jù)類型int、char和double所占用內(nèi)存字節(jié)數(shù)分別是: ()。A. 4、 2
18、 和 8B. 2、 2 和 4C. 2、 1 和 8D. 4、 4 和 4正確答案: A21.(單選 )關(guān)于 String 和 StringBuffer 下面說法正確的是()。A. String 操作字符串不改變?cè)凶址膬?nèi)容B. StringBuffer連接字符串速度沒有 String快C. String可以使用append方法連接字符串D. StringBuffer 在 java.util 包中正確答案: A22.(單選 )運(yùn)行下面的程序:int a = 100; int b = 200; a = a + b; b = a - b;a = a - b; System.out.printl
19、n("a=" + a + ", b=" + b); 輸出的結(jié)果是: ()。A. a=100, b=300B. a=100, b=200C. a=200, b=100D. a=300, b=200正確答案: C23.(單選)下列代碼的輸出結(jié)果是: public class Yikes public static void go(Long n) System.out.println("Long"); public static void go(Short n) System.out.println("Short");
20、public static void go(int n) System.out.println("int"); public static void main(String args) short y = 6; long z = 7; go(y); go(z); A. Long LongB. Short LongC. int LongD. int int正確答案: C24.(單選)分析如下語(yǔ)句,說法錯(cuò)誤的是()。A. break 可用于跳出循環(huán),當(dāng)多層嵌套時(shí),只用于跳出一層循環(huán)B. break 即可以出現(xiàn)在循環(huán)語(yǔ)句中也可以出現(xiàn)在 switch 語(yǔ)句中C. continue
21、可以用于跳出循環(huán)D. continue 不能出現(xiàn)在 switch 語(yǔ)句中 正確答案: C(單選)A 類中有一個(gè)方法:protected int print(String str),B 類繼承A類,以下方法能在B類中重寫A類中print()方法的是:()。A. public int print(String str)B. private int print(String str)C. private void print(String str)D. public void print(String str)正確答案: A26.(單選)下列代碼的運(yùn)行結(jié)果是:String test = "
22、Test A. Test B. TestC. " String regex = ".s*" String result = test.split(regex); for (String s : result) System.out.print(s + " ");A. Test A Test B Test CB. Test A. Test B. Test C.C. Test . Test . Test .D. A. B. C.正確答案: A27.(單選 )請(qǐng)看下列代碼 public class Member private Long userId
23、; private String nickName; / 以下是 getter 禾口 sett 方法 Main方法中的代碼: Member m1=new Member(); m1.setUserId(newLong(100001); m1.setNickName("mick"); Member m2=newMember(); m2.setUserId(new Long(100001);m2.setNickName("mick"); System.out.println(m1=m2);System.out.println(m1.equals(m2); 控制
24、臺(tái)的輸出結(jié)果是:A. true falseB. false trueC. false falseD. true ture正確答案: C28.(單選)實(shí)現(xiàn) Point 類的 equals 方法,具體邏輯為:“成員變量 x 和 y 分別相等的 Point 對(duì)象被視為相等”。 public class Point private int x; private int y; . public boolean equals(Object obj) 填入代碼 插入代碼處應(yīng)填入的代碼正確的是 :A. if(obj.x = this.x | obj.y = this.y) return true; retur
25、n false;B. if(obj.x = this.x && obj.y = this.y) return true; return false;C. if(!(obj instanceof Point) return false; if(Point)obj).x =(Point)obj).y && this.x = this.y) return true; return false;D. if(!(obj instanceof Point) return false; if(Point)obj).x = this.x && (Point)ob
26、j).y = this.y) return true; return false;正確答案: D29.(單選)運(yùn)行下列代碼,輸出為 false 的是:()。A. String st1 = "abc" System.out.println("abc" = st1);B. String st2 = "abc" System.out.println(st2.equals(newString("abc");C. Integer i = 100; System.out.println(100 = i);D. ArrayLis
27、t list = new ArrayList();System.out.println(list.contains(null);正確答案: D30.(單選)請(qǐng)看下列代碼,出現(xiàn)錯(cuò)誤的行是:()public interfaceCookie Cookie cookie=new Cart ("小面包 ","盼盼"); public class Cart implements Cookie private String name; private String production; public Cart(String name,Stringproduction
28、) =name; duction=production; public void smell() cookie =new Cart(”蛋黃派","達(dá)利園"); A. 第2行B第4行C第11行D第12行正確答案: D31.(單選)請(qǐng)看下列代碼的輸出結(jié)果是:public class Bootchy int bootch; String snootch; public Bootchy() this("snootchy");System.out.print("first "); public Boo
29、tchy(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(); System.out.print
30、(b.snootch + " " + b.bootch); A. first second third snootchy 420B. third second first snootchy 420C. third first second snootchy 420D. first second first third snootchy 420正確答案: B32.(單選)下列語(yǔ)句創(chuàng)建對(duì)象的總個(gè)數(shù)是: ()。 String s=”a”+”b” +”c”+”d”+”e”;A. 1B. 2C. 3D. 4正確答案: A33.(單選)下面的代碼用于對(duì)數(shù)組 arr 實(shí)現(xiàn)冒泡排序: fo
31、r (int i = 0; i < arr.length - 1; i+) boolean isSwap = false; 空白處 if (!isSwap) break; 下列選項(xiàng)中,空白處可以填入的代碼是:()。A. for (int j = arr.length - 1; j > i; j-) if (arrj < arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; B. for (int j = arr.length - 1; j > 0; j-) if (arrj
32、 < 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; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; D. for (int j = i; j< arr.length; j+) if (arrj < arrj - 1) int temp = arrj; a
33、rrj = arrj - 1; arrj - 1 = temp; isSwap = true; 正確答案: A34.(單選)請(qǐng)看下列代碼: class Payload private int weight; public Payload(int wt) weight = wt; public Payload() public void setWeight(int w) weight = w; public String toString() return Integer.toString(weight); public class TestPayload static void changeP
34、ayload(Payload p) <插入代碼 > public static void main(String args) Payload p = new Payload(); p.setWeight(1024); changePayload(p); System.out.println("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 = n
35、ew Payload(420);D. p = new Payload(); p.setWeight(420); 正確答案: A 35.(單選)下列代碼運(yùn)行的結(jié)果是 ()。 public class Base public static final String FOO = "foo" public static void main(String args) Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.prin
36、t(b.FOO); System.out.print(s.FOO); System.out.print(Base) s).FOO); class Sub extends Base public static final String FOO = "bar" A. foofoofoofoofooB. foobarfoobarbarC. foobarfoofoofooD. foobarfoobarfoo正確答案: D36.(多選)請(qǐng)看下列代碼: public abstract class Shape int x; int y; public abstract void draw
37、(); public void setAnchor(int x, int y) this.x = x; this.y = y; 下列選項(xiàng)中能正確使用 Shape 類的是:A. public class Circle implements Shape private int radius; B. public abstract class Circle extends Shape private int radius; C. public class Circle extends Shape private int radius; public void draw(); D. public cl
38、ass Circle extends Shape private int radius; public void draw() /* code here */ 正確答案: BD37.侈選)在Java語(yǔ)言中,下列說法正確的是()。A. 個(gè)接口可以繼承多個(gè)接口B. 個(gè)類可以繼承多個(gè)類C一個(gè)類可以實(shí)現(xiàn)多個(gè)接口D. 個(gè)類可以有多個(gè)子類 正確答案: ACD38.(多選)請(qǐng)看下列代碼: package com.tarena; public class Geodetics public static final double DIAMETER = 12756.32; 訪問靜態(tài)常量DIAMETER的方式正確的
39、是:A. import com.tarena.Geodetics; public class TerraCarta public double halfway() return Geodetics.DIAMETER/2.0; B. import com.tarena.Geodetics; public class TerraCarta public double halfway() return DIAMETER/2.0; C. import com.tarena; public class TerraCarta public double halfway() return Geodetics
40、.DIAMETER2/.0; D. import com.tarena.*; public class TerraCarta public double halfway() return Geodetics.DIAMETER2/.0; 正確答案: AD 39.(多選)請(qǐng)看下列代碼 public class Foo public void method(String str,int age) 和 Foo 類中 method 方法重載的方法是 :A. public int method(String str,int age)B. public void method(String s,int ye
41、ar)C. public void method(int year,String s)D. public int method(int year,String s)正確答案: CD40.(多選)在<插入代碼 >處,填入下列代碼編譯正確的是:public voidfoo(int x) < 插入代碼 > A. foreach(int z : x) System.out.println(z);B. for(int z : x) System.out.println(z);C. while( x.hasNext() System.out.println( x.next();D.
42、 for( int i=0; i< x.length; i+ ) System.out.println(xi);正確答案: BD41.(多選)查看如下代碼:class A protected int method (int a, int b) return 0; 下列選項(xiàng)中,可以在 A的子類中使用的是()。A. public int method (int a, int b) return 0; B. private int method(int a, int b) return 0; C. private int method(int a, long b) return 0; D. p
43、ublic short method(int a, int b) return 0; 正確答案: AC 42. (多選)題目代碼的功能為:輸出每個(gè)字符在一個(gè)字符串中出現(xiàn)的 次數(shù) (不區(qū)分大小寫 )。 String str = "ewrwqFrewqfsadfdsfdsfs" str=str.toLowerCase(); int max_length = 0; while (str.length() > 0) 插入代碼 A. int length = str.length(); char first=str.charAt(0); String strNew = str.
44、replaceAll(String.valueOf(first), ""); if (length>strNew.length() max_length = length - strNew.length(); System.out.println(first+":"+max_length); B. int length = str.length(); char first=str.charAt(0); String strNew = str.replaceAll(String.valueOf(first), ""); if (l
45、ength>strNew.length() max_length = length - strNew.length(); str = strNew; System.out.println(first+":"+max_length); C. int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, ""); if (length>strNew.length() max_length = length -
46、 strNew.length(); str = strNew; System.out.println(first+":"+max_length); D. int length = str.length(); String first = str.substring(0, 1); String strNew = str.replaceAll(first, ""); if (length>strNew.length() max_length = length - strNew.length();System.out.println(first+&quo
47、t;:"+max_length); 正確答案: BC 43.侈選)在Java語(yǔ)言中,下列說法正確的是:()。A. StringBuffer 和 StringBuilder 的區(qū)別在于: StringBuffer 是線程 安全的而 StringBuilder 不是。B. String是不可變對(duì)象,而StringBuffer中封裝的字符串?dāng)?shù)據(jù)是 可以動(dòng)態(tài)改變的。C判斷兩個(gè)StringBuilder對(duì)象的字符序列是否相同,可以調(diào)用其 equlas 方法進(jìn)行比較。D.String的重寫了 equals方法,重寫的邏輯是:字符序列相同的String 對(duì)象 equals 方法返回 true。正確答案:ABD44.(多選 )下面的方法屬于 StringBuffer 的是:()。A. sizeB. insertC. deleteD. length正確答案: BCD(多選)請(qǐng)看下列代碼:public class Old public static Object get(Listlist) return list.get(0); 以下選項(xiàng)調(diào)用 get 方法,能編譯通過的 是:A. Object o = Old.get(new LinkedList();B. Object o = Old.get(new LinkedList<?>();C. String s = Old.g
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 技術(shù)咨詢支持服務(wù)合同協(xié)議書
- 罕見病藥物研發(fā)激勵(lì)政策在2025年推動(dòng)罕見病藥物國(guó)際化進(jìn)程的報(bào)告
- 共享廚房在餐飲業(yè)節(jié)能減排中的應(yīng)用與發(fā)展報(bào)告
- 2025年醫(yī)療健康產(chǎn)業(yè)政策環(huán)境與行業(yè)機(jī)遇分析報(bào)告
- 2025年工業(yè)互聯(lián)網(wǎng)平臺(tái)AR交互技術(shù)在虛擬現(xiàn)實(shí)旅游中的虛擬旅游報(bào)告
- 學(xué)前教育信息化與幼兒地理教育研究報(bào)告
- 城市生活垃圾分類處理長(zhǎng)效機(jī)制與公眾參與度提升策略研究
- 資源型城市綠色轉(zhuǎn)型中的廢棄物資源化與再生利用報(bào)告
- 城市雨水徑流控制2025年海綿城市建設(shè)實(shí)施方案與生態(tài)水系構(gòu)建報(bào)告
- 實(shí)驗(yàn)室POCT比對(duì)分析報(bào)告表
- 北京朝陽(yáng)區(qū)2024年八年級(jí)物理第二學(xué)期期末綜合測(cè)試試題及答案解析
- 服務(wù)標(biāo)準(zhǔn)化指標(biāo)的量化與評(píng)價(jià)
- 維修結(jié)算單完整版本
- (正式版)JBT 14790-2024 往復(fù)式內(nèi)燃機(jī)曲軸轉(zhuǎn)角 信號(hào)盤
- 勘察設(shè)計(jì)工作量及計(jì)劃安排方案
- T-CSEM 0024-2024 智慧消防 火災(zāi)防控系統(tǒng)建設(shè)要求
- 嗆咳病人的護(hù)理措施
- 2023年北京中儲(chǔ)糧集團(tuán)招聘考試真題及答案
- 智能問答系統(tǒng)課件
- 愛德華消防主機(jī)更換煙感編程
- 【公開課教案】《蹲踞式起跑》教案
評(píng)論
0/150
提交評(píng)論