![達(dá)內(nèi)JSD1412第一次月考試題及答案(共16頁)_第1頁](http://file4.renrendoc.com/view/249f6f1300996d3fcd278bfa16d668dd/249f6f1300996d3fcd278bfa16d668dd1.gif)
![達(dá)內(nèi)JSD1412第一次月考試題及答案(共16頁)_第2頁](http://file4.renrendoc.com/view/249f6f1300996d3fcd278bfa16d668dd/249f6f1300996d3fcd278bfa16d668dd2.gif)
![達(dá)內(nèi)JSD1412第一次月考試題及答案(共16頁)_第3頁](http://file4.renrendoc.com/view/249f6f1300996d3fcd278bfa16d668dd/249f6f1300996d3fcd278bfa16d668dd3.gif)
![達(dá)內(nèi)JSD1412第一次月考試題及答案(共16頁)_第4頁](http://file4.renrendoc.com/view/249f6f1300996d3fcd278bfa16d668dd/249f6f1300996d3fcd278bfa16d668dd4.gif)
![達(dá)內(nèi)JSD1412第一次月考試題及答案(共16頁)_第5頁](http://file4.renrendoc.com/view/249f6f1300996d3fcd278bfa16d668dd/249f6f1300996d3fcd278bfa16d668dd5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、考試場次(chngc):2015_01月月考_01月29日_JAVA 試卷名稱:2015年01月_JSD_JSD14121. 運(yùn)行下面(xi mian)的程序: int a = 100; int b = 200; a = a + b; b = a - b; a = a - b; System.out.println(a= + a + , b= + b); 輸出(shch)的結(jié)果是:()。 A. a=100, b=300 B. a=100, b=200 C. a=200, b=100 D. a=300, b=200正確答案:C2. 下面關(guān)于數(shù)組的聲明語句中,有編譯錯誤的是:()。 A. int
2、arr = new int1,2,3; B. int arr = null;arr = 1,2,3,4,5; C. int arr = new int1,2,3,4,5,6 D. int arr = new int2;正確答案:B3. 分析如下代碼,輸出結(jié)果為()。 public static void main(String args) int i = 0; boolean re = false; re = (+i) + i = 2) ? true : false; System.out.println(i= + i + ,re=+re); A. i=1,re=true B. i=0,re=
3、true C. i=1,re=false D. i=0,re=false正確答案:A4. 請看下列代碼:interface Foo int bar();public class Sprite public int fubar(Foo foo) return foo.bar(); public void testFoo() fubar( ); 使類Sprite編譯(biny)通過,在處應(yīng)填入的代碼是: A. Foo public int bar() return 1; B. new Foo public int bar() return 1; C. new Foo() public int ba
4、r()return 1; D. new class Foo public int bar() return 1; 正確(zhngqu)答案:C 5. 程序的執(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(true); else System.out.println(false); if(
5、str1=str3) System.out.println(true); else System.out.println(false); A. true true B. truefalse C. false true D. false false正確答案:A6. 下列代碼(di m)的輸出結(jié)果是:()。 public class StaticFoo int num; static int x; public static void main(String args) StaticFoo foo1 = new StaticFoo (); foo1.num+; foo1.x+; StaticFoo
6、 foo2 = new StaticFoo (); foo2.num+; foo2.x+; StaticFoo foo3 = new StaticFoo (); foo3.num+; foo3.x+; StaticFoo.x+; System.out.print(foo3.num+,); System.out.println(foo3.x); A. 3,3 B. 1,3 C. 3,4 D. 1,4 正確(zhngqu)答案:D7. 運(yùn)行下面(xi mian)的程序:Calendar c = Calendar.getInstance();c.set(Calendar.YEAR, 2012);c.
7、set(Calendar.MONTH, Calendar.SEPTEMBER);c.set(Calendar.DATE, 31);SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd);System.out.println(sdf.format(c.getTime(); 輸出的結(jié)果是:()。 A. 2012-10-1 B. 2012-10-01 C. 2012-09-30 D. 2012-9-30正確答案:B8. 下列關(guān)于JVM說法,錯誤的是()。 A. JVM通過專門的線程實(shí)現(xiàn)內(nèi)存的回收。 B. 使用java命令時,可以通過參數(shù)來設(shè)置分
8、配JVM的內(nèi)存大小。 C. JRE包括JVM及Java核心類庫。 D. 目前主流版本JVM通過純解釋的方式運(yùn)行Java字節(jié)碼。正確答案:D9. 請看下列代碼: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() 下列說法(shuf)正確的是: A. 在Tree類中
9、添加(tin ji)代碼:public Tree() Plant(); ,編譯(biny)將通過 B. 在Plant類中添加代碼:public Plant() Tree(); ,編譯將通過 C. 在Plant類中添加代碼:public Plant() this(”fern”); ,編譯將通過 D. 在Plant類中添加代碼:public Plant() Plant(”fern”); ,編譯將通過正確答案:C10. 運(yùn)行下列程序: String str = *java*java*java*; String str1 = java; int index = 0; while (index = st
10、r.indexOf(str1, index) != -1) System.out.print(index+”); index += str1.length(); 控制臺輸出的結(jié)果是:()。 A. 1 8 17 B. 2 9 18 C. 5 12 21 D. 6 13 22正確答案:B11. 下列語句創(chuàng)建對象的總個數(shù)是:()。 String s=”a”+”b”+”c”+”d”+”e”; A. 1 B. 2 C. 3 D. 4 正確答案:A 12. 下列代碼的輸出結(jié)果是()。 int j=0; for(int i=0;i100;i+) j=j+; System.out.println(j); A.
11、 0 B. 99 C. 100 D. 101 正確答案:A13. 下列代碼編譯和運(yùn)行的結(jié)果是() public class Foo public static void main(String args) java.util.List list = new java.util.ArrayList(); list.add(new B(); list.add(new C(); for (A a : list) a.x(); a.y(); interface A void x(); class B implements A public void x() public void y() class
12、C extends B public void x() A. 代碼運(yùn)行沒有(mi yu)輸出 B. 運(yùn)行時拋出(po ch)異常 C. 代碼(di m)a.y();行,編譯錯誤 D. 代碼java.util.List list = new java.util.ArrayList();行,編譯錯誤正確答案:C14. 下面的程序可以輸出1100內(nèi)前10個3的倍數(shù): for (int i = 1, count = 0; i = 10) break; B. if (+count = 10) break; C. if (count+ = 10) continue; D. if (+count = 10)
13、 continue;正確答案:B 15. 請看下列代碼: public class Person private String name; public Person(String name) = name; public boolean equals(Person p) return .equals(); 下列說法正確的是: A. Person類的equals方法沒有覆蓋Object類的equals方法 B. 編譯錯誤,因為私有屬性不能在equals方法中被訪問 C. 基于Hash的數(shù)據(jù)結(jié)構(gòu)可以正確工作,但是Person類必須覆蓋hashCo
14、de方法 D. 當(dāng)向Set集合中添加Person對象時,equals方法中的return語句能避免重復(fù)正確答案:A16. 有變量聲明如下: short b = 120; 下列語句中,錯誤的是()。 A. short s = b; B. int i = b; C. byte s1 = b; D. long l = b;正確(zhngqu)答案:C 17. Java程序(chngx)的執(zhí)行過程中用到一套JDK工具,其中javac.exe是指()。 A. Java語言(yyn)編譯器 B. Java字節(jié)碼解釋器 C. Java文檔生成器 D. Java類分解器正確答案:A18. 以下程序的輸出結(jié)果是
15、: ()。 public class Super public Super() System.out.println(Super ); public class Sub extends Super public Sub() System.out.println(Sub); public static void main(String args) Super fc = new Super(); Sub cc = new Sub(); A. Super Super Sub B. Super Sub C. Sub Super D. Super Sub Sub 正確答案:A19. 下列代碼的輸出結(jié)果是
16、()。 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 D. 1, 3, 6, 8, 9正確答案:D20. 實(shí)現(xiàn)Point類的equals方法,具體邏輯為:“成員變量x和y分別相等的Point對象被視為相等”。publi
17、c 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; return 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 = (Poi
18、nt)obj).y & this.x = this.y) return true; return false; D. if(!(obj instanceof Point) return false; if(Point)obj).x = this.x & (Point)obj).y = this.y) return true; return false;正確(zhngqu)答案:D21. 下列(xili)數(shù)組聲明語句中,錯誤的是:()。 A. int arr = new int; B. int arr = new int; C. int arr = ; D. int arr = new int2
19、正確(zhngqu)答案:B22. 下面關(guān)于interface,敘述錯誤的是:() A. 一個interface可以繼承多個interface B. 接口中的方法可以由private修飾 C. interface中可以定義static final 常量 D. interface中可以無任何方法定義 正確答案:B23. 關(guān)于下列代碼說法不正確的是:10. interface Foo 11. int bar();12. 13.14. public class Beta 15.16. class A implements Foo 17. public int bar() return 1; 18.
20、19.20. public int fubar( Foo foo) return foo.bar(); 21.22. public void testFoo() 23.24. class A implements Foo 25. public int bar() return 2; 26. 27.28. System.out.println( fubar( new A();29. 30.31. public static void main( String argv) 32. new Beta().testFoo();33. 34. A. 編譯(biny)錯誤 B. 運(yùn)行(ynxng)代碼輸出
21、:2 C. 如果刪除16,17,18行,運(yùn)行代碼(di m)應(yīng)然輸出:2 D. 如果刪除24,25,26行,運(yùn)行代碼輸出:1正確答案:A 24. 下列代碼的輸出結(jié)果是:class Cup class PoisonCup extends Cup public void takeCup(Cup c) if (c instanceof PoisonCup) System.out.println(Inconceivable!); else if (c instanceof Cup) System.out.println(Dizzying intellect!); else System.exit(0)
22、; public class TestCup public static void main(String args) Cup cup = new PoisonCup(); PoisonCup poison=new PoisonCup(); poison.takeCup(cup); A. Inconceivable! B. Dizzying intellect! C. 代碼正常運(yùn)行,但是無輸出 D. 拋出運(yùn)行時異常正確答案:A 25. 下列(xili)關(guān)于HashMap的方法描述正確的是: A. containsKey(Object key): 判斷集合(jh)中是否包含指定的Value B.
23、 containsValue (Object value): 判斷集合中是否(sh fu)包含指定的Key C. get(Object key):返回與參數(shù)Key所對應(yīng)的Value對象,如果不存在則返回null D. put(K key, V value):將Key-Value對存入Map,如果在集合中已經(jīng)包含該Key,則操作將替換該Key所對應(yīng)的Value,返回值為該Key當(dāng)前所對應(yīng)的Value(如果沒有則返回null)正確答案:C 26. 查看如下代碼: 1. class HasStatic 2. private static int x=100; 3. public static voi
24、d main(String args ) 4. HasStatic hs1=new HasStatic( ); 5. hs1.x+; 6. HasStatic hs2=new HasStatic( ); 7. hs2.x+; 8. hs1=new HasStatic( ); 9. hs1.x+; 10. HasStatic.x-; 11. System.out.println(“x=”+x); 12. 13. 對于此代碼,下列描述中,正確的是()。 A. 5行不能通過編譯,因為引用了私有靜態(tài)變量 B. 10行不能通過編譯,因為x是私有靜態(tài)變量 C. 程序通過編譯,輸出結(jié)果為:x=103 D.
25、程序通過編譯,輸出結(jié)果為:x=102正確答案:D27. 在Java語言中,下列說法正確的是:()。 A. Java訪問修飾符按照訪問范圍由低到高的排列順序是public,default,protected,private B. private可以用于外部類的聲明 C. 一個Java源文件中聲明為public的外部類只能有一個 D. protected聲明的方法不可以被子類重寫正確答案:C28. 下列代碼運(yùn)行的結(jié)果是()。 public class Base public static final String FOO = foo; public static void main(String
26、args) Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(Base) s).FOO); class Sub extends Base public static final String FOO = bar; A. foofoofoofoofoo B. foobarfoobarbar C. foobarfoofoofoo
27、 D. foobarfoobarfoo正確答案:D29. 在Java中,Integer.MAX_VALUE表示: A. double型最大值 B. int最大值 C. long型最大值 D. char型最大值正確(zhngqu)答案:B30. 請看下列(xili)代碼: public static void main(String args) Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2013); c.set(Calendar.MONTH, Calendar.FEBRUARY); c.set(Calendar.DATE,
28、 28); 在處填入將Calendar表示的日期轉(zhuǎn)換為Date表示的日期: A. Date d=c.getDate(); B. Date d=c.getCalendar(); C. Date d=c.getNow(); D. Date d=c.getTime();正確答案:D31. 題目代碼的功能為:輸出每個字符在一個字符串中出現(xiàn)的次數(shù)(不區(qū)分大小寫)。String str = ewrwqFrewqfsadfdsfdsfs;str=str.toLowerCase();int max_length = 0;while (str.length() 0) 插入代碼 A. int length = s
29、tr.length();char first=str.charAt(0);String strNew = str.replaceAll(String.valueOf(first), );if (lengthstrNew.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(fi
30、rst), );if (lengthstrNew.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 (lengthstrNew.length() max_length = length - strNew.length(); str
31、= strNew; System.out.println(first+:+max_length); D. int length = str.length();String first = str.substring(0, 1);String strNew = str.replaceAll(first, );if (lengthstrNew.length() max_length = length - strNew.length(); System.out.println(first+:+max_length);正確(zhngqu)答案:BC32. 請看下列(xili)代碼: public cl
32、ass Old public static Object get(List list) return list.get(0); 以下選項調(diào)用get方法(fngf),能編譯通過的是: A. Object o = Old.get(new LinkedList(); B. Object o = Old.get(new LinkedList(); C. String s = Old.get(new LinkedList(); D. String s = (String)Old.get(new LinkedList();正確答案:AD33. 下列賦值語句中,會有編譯錯誤的是()。 A. int a =
33、8888888888; B. char b = 1000+300; C. byte c = 100+30; D. int d = a+b+c;正確答案:AC34. 所謂“水仙花”數(shù)是一個整數(shù)等于各位數(shù)字立方的和,例如:153 = 1*1*1+5*5*5+3*3*3,下面的程序用于輸出21000內(nèi)的水仙花數(shù): for (int n = 2; n 0) int t = n1 % 10; s += t * t * t; n1 /= 10; B. int s = 0, n1 = n;while (n1 0) int t = n1 / 10; s+= t * t * t; n1 %= 10; C. in
34、t s = 0;for(int n1 = n; n10; n1 /= 10) int t = n1%10; s += t * t * t; D. int s = 0; for(int n1 = n; n10; n1 %= 10) int t = n1 / 10; s += t * t * t; 正確(zhngqu)答案:AC 35. 請看下列(xili)代碼:class One public One foo() return this; class Two extends One public One foo() return this; class Three extends Two 下列選
35、項中的代碼,放置在處無編譯錯誤的是: A. public void foo() B. public Object foo() return this; C. public Two foo() return this; D. public One foo() return this; 正確答案:CD 36. 在Java語言中,下列說法正確的是:()。 A. StringBuffer和StringBuilder的區(qū)別在于:StringBuffer是線程安全的而StringBuilder不是。 B. String是不可變對象,而StringBuffer中封裝的字符串?dāng)?shù)據(jù)是可以動態(tài)改變的。 C. 判斷
36、兩個(lin )StringBuilder對象的字符序列是否相同,可以調(diào)用其equlas方法進(jìn)行比較。 D. String的重寫了equals方法,重寫的邏輯(lu j)是:字符序列相同的String對象equals方法返回true。正確(zhngqu)答案:ABD 37. 下列關(guān)于HashMap的描述正確的是: A. HashMap的Key和Value是以鏈表的方式存入對應(yīng)的bucket B. HashMap的查找方式是獲取Key的hashCode值,通過hash算法確定存儲的bucket,調(diào)用equals方法依次與bucket中的Key進(jìn)行比較 C. 放入HashMap集合中的元素按照ke
37、y的自然順序排序 D. HashMap中的key是不可以的重復(fù)的正確答案:ABD38. 在Java語言中,下列說法正確的是()。 A. 一個接口可以繼承多個接口 B. 一個類可以繼承多個類 C. 一個類可以實(shí)現(xiàn)多個接口 D. 一個類可以有多個子類正確答案:ACD 39. 請看下列代碼:public abstract class Shape int x; int y; public abstract void draw(); public void setAnchor(int x, int y) this.x = x; this.y = y; 下列選項中能正確使用Shape類的是: A. pub
38、lic 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 class Circle extends Shape private int radius;public void draw() /* code here */正確(zhngqu)答案:B
39、D40. 在處,填入下列代碼編譯正確的是: public void foo(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. for( int i=0; i x.length; i+ ) System.out.println(xi);正確答案:BD41. 閱讀理解 public class A public A() System.out.print(A
40、 ); public A(String s) System.out.print(s); public void fun() System.out.println(A.fun(); public class B extends A public B() System.out.print(B ); public B(String s) super(s); public void fun() System.out.println(B.fun(); public void sun() System.out.println(B.sun(); public static void Main() A a =
41、 new B(); a.fun(); (1). 下列關(guān)于上述代碼中構(gòu)造方法的描述,錯誤的是()。 A. 實(shí)例化對象 a 時,將默認(rèn)調(diào)用父類的無參構(gòu)造方法 B. 類 B中使用 super 關(guān)鍵字,是為了調(diào)用父類的含有一個參數(shù)的構(gòu)造方法 C. 實(shí)例化對象 a 時,父類A和子類B的構(gòu)造方法都會被調(diào)用到 D. 實(shí)例化父類對象時,調(diào)用父類 A 的構(gòu)造方法;實(shí)例化子類對象時,則只調(diào)用子類B的構(gòu)造方法正確答案:D(2). 該代碼運(yùn)行后,輸出為:()。 A. A B A.fun() B. A B B.fun() C. B A A.fun() D. B A B.fun()正確答案:B(3). 如果 main 方
42、法中如此調(diào)用: public static void main(String args) A a = new B(Hello,); a.fun(); 其他代碼不變,該代碼運(yùn)行后,輸出為:()。 A. A A.fun() B. B A.fun() C. Hello,A.fun() D. Hello,B.fun()正確答案:D(4). 如果 main 方法中如此調(diào)用: public static void main(String args) A a = new A(); a.sun(); 其它代碼不變,下列說法正確的是:()。 A. 運(yùn)行輸出結(jié)果為:A B.sun() B. 運(yùn)行輸出結(jié)果為:A B B.sun()
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 精準(zhǔn)醫(yī)療合作治療項目合同
- 公司與個體房屋出租協(xié)議
- 山塘承包合同適用復(fù)雜情況
- 車輛礦石運(yùn)輸合同
- 綠色建筑技術(shù)研發(fā)合同
- 新材料生產(chǎn)綠色環(huán)保技術(shù)應(yīng)用推廣合作協(xié)議
- Module 3 Journey to space Unit 1 (教學(xué)設(shè)計)-2023-2024學(xué)年外研版英語八年級下冊
- 月子中心房屋振動限制協(xié)議
- 13我能行 教學(xué)設(shè)計 -2023-2024學(xué)年道德與法治二年級下冊(統(tǒng)編版)
- 家具廠白蟻防治施工方案
- 高壓氧科工作總結(jié)高壓氧科個人年終總結(jié).doc
- 電子電路基礎(chǔ)習(xí)題解答
- 《政治學(xué)概論》教學(xué)大綱
- 食品生物化學(xué)習(xí)題謝達(dá)平(動態(tài))
- 保安員工入職登記表
- 斷路器控制回路超詳細(xì)講解
- 簽證戶口本完整翻譯模板
- 睿達(dá)RDCAM激光雕刻切割軟件V5.0操作說明書
- 變電設(shè)備運(yùn)行與維護(hù)培訓(xùn)課件(共102頁).ppt
- 機(jī)械設(shè)計基礎(chǔ)平面連桿機(jī)構(gòu)課件
- 寒假學(xué)習(xí)計劃表-
評論
0/150
提交評論