《Java面向?qū)ο蟆饭P試3套_第1頁
《Java面向?qū)ο蟆饭P試3套_第2頁
《Java面向?qū)ο蟆饭P試3套_第3頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、 Java 面向?qū)ο缶幊踢x擇題(單選 50 題)1. 欲構(gòu)造 ArrayList類的一個(gè)實(shí)例,此類繼承了A、 ArrayList myList=new Object();B、 List myList=new ArrayList();C、 ArrayList myList=new List();D、 List myList=new List();List接口,下列哪個(gè)方法是正確的?2.paint()方法使用哪種類型的參數(shù)?A、 GraphicsB、 Graphics2DC、 StringD、 Color3. 指出正確的表達(dá)式A、 byte=128;B、 Boolean=null;C、 long

2、l=0xfffL;D、 double=0.9239d;4. 指出下列程序運(yùn)行的結(jié)果public class ExampleString str=new String("good");charch='a','b','c'public static void main(String args)Example ex=new Example();ex.change(ex.str,ex.ch);System.out.print(ex.str+" and ");Sytem.out.print(ex.ch);public

3、 void change(String str,char ch)str="test ok"ch0='g'A、 good and abcB、 good and gbcC、 test ok and abcD、 test ok and gbc5. 運(yùn)行下列程序 , 會(huì)產(chǎn)生什么結(jié)果public class X extends Thread implements Runnablepublic void run()System.out.println("this is run()");public static void main(String ar

4、gs)Thread t=new Thread(new X();t.start();A、 第一行會(huì)產(chǎn)生編譯錯(cuò)誤B、 第六行會(huì)產(chǎn)生編譯錯(cuò)誤C、 第六行會(huì)產(chǎn)生運(yùn)行錯(cuò)誤D、 程序會(huì)運(yùn)行和啟動(dòng)6. 要從文件 " file.dat" 文件中讀出第 10 個(gè)字節(jié)到變量 C中 , 下列哪個(gè)方法適合 ? A、 FileInputStream in=new FileInputStream("file.dat"); in.skip(9); intc=in.read();B、 FileInputStream in=new FileInputStream("file.d

5、at"); in.skip(10); intc=in.read();C、 FileInputStream in=new FileInputStream("file.dat"); int c=in.read();D、 RandomAccessFile in=new RandomAccessFile("file.dat"); in.skip(9); int c=in.readByte();7. 容器被重新設(shè)置大小后,哪種布局管理器的容器中的組件大小不隨容器大小的變化而改變?A、 CardLayoutB、 FlowLayoutC、 BorderLay

6、outD、 GridLayout8. 給出下面代碼:public class Personstatic int arr = new int10;public static void main(String a)System.out.println(arr1);那個(gè)語句是正確的?A、 編譯時(shí)將產(chǎn)生錯(cuò)誤;B、 編譯時(shí)正確,運(yùn)行時(shí)將產(chǎn)生錯(cuò)誤;C 、輸出零;D、 輸出空。9. 哪個(gè)關(guān)鍵字可以對(duì)對(duì)象加互斥鎖?A、 transientB synchronizedC serializeD static10. 下列哪些語句關(guān)于內(nèi)存回收的說明是正確的?A、 程序員必須創(chuàng)建一個(gè)線程來釋放內(nèi)存;B、 內(nèi)存回收程序負(fù)

7、責(zé)釋放無用內(nèi)存C、內(nèi)存回收程序允許程序員直接釋放內(nèi)存D、內(nèi)存回收程序可以在指定的時(shí)間釋放內(nèi)存對(duì)象11. 下列代碼哪幾行會(huì)出錯(cuò) : 1) public void modify() 2) int I, j, k;3) I = 100;4) while ( I > 0 ) 5) j = I * 2;6) System.out.println (" The value of j is " + j );7) k = k + 1;8) I-;9) 10 A、 line 4B、 line 6C、 line 7D、 line 812.MAX_LENGTH是 int型 public成員

8、變量 ,變量值保持為常量100,用簡(jiǎn)短語句定義這個(gè)變量。A、 public int MAX_LENGTH=100;B、 final int MAX_LENGTH=100;C、 final public int MAX_LENGTH=100;D、 public final int MAX_LENGTH=100.13. 給出下面代碼:1) class Parent 2 private String name;3 public Parent()4 5) public class Child extends Parent 6 private String department;7 public Chi

9、ld() 8 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent();11 12 那些行將引起錯(cuò)誤?A、第3行B、第6行C、第7行D、第8行14. 類 Teacher 和 Student 是類 Person 的子類; Person p;Teacher t; Student s;/p, t and s are all non-null.if(t instanceof Person) s = (Student)t; 最后一句語句的結(jié)果是:A、 將構(gòu)造

10、一個(gè)Student 對(duì)象;B、 表達(dá)式是合法的;C、 表達(dá)式是錯(cuò)誤的;D、 編譯時(shí)正確,但運(yùn)行時(shí)錯(cuò)誤。15. 給出下面代碼段1) public class Test 2) int m, n;3) public Test() 4) public Test(int a) m=a; 5) public static void main(String arg) 6) Test t1,t2;7) int j,k;8) j=0; k=0;9) t1=new Test();10) t2=new Test(j,k);11) 12) 哪行將引起一個(gè)編譯時(shí)錯(cuò)誤?A、 line 3B、 line 5C、 line

11、6D、 line 1016. 對(duì)于下列代碼:1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public class Teacher extends Person 6) public void printValue() /. 7) public void printValue(int i) /.8) public static void main(String args)9) Person t = new Teacher();10) t.pri

12、ntValue(10);11) 第 10 行語句將調(diào)用哪行語句? ? A、 line 2B、 line 3 C、 line 6 D、 line 717. 哪個(gè)關(guān)鍵字可以拋出異常?A、 transientB、 finallyC、 throwD、 static18.下面關(guān)于構(gòu)造函數(shù)的說法不正確的是()A、構(gòu)造函數(shù)也屬于類的方法,用于創(chuàng)建對(duì)象的時(shí)候給成員變量賦值。B、構(gòu)造函數(shù)不可以重載。C、構(gòu)造函數(shù)沒有返回值。D、構(gòu)造函數(shù)一定要和類名相同。19.System 類在哪個(gè)包中?A、 java.utilB、 java.ioC、 java.awtD、 java.lang20. 對(duì)于下列代碼: public

13、class Parent public int addValue( int a, int b) int s;s = a+b;return s;class Child extends Parent 下述哪些方法可以加入類Child?A、 int addValue( int a, int b )/ do something.B、 public void addValue (int a, int b )/ do something.C、 public int addValue( int a )/ do something.D、 public int addValue( int a, int b )t

14、hrows MyException /do something.21. 給出下面代碼:public class teststatic int a = new a10;public static void main(String args) System.out.println(arr10);那個(gè)選項(xiàng)是正確的?A、 編譯時(shí)將產(chǎn)生錯(cuò)誤;B、 編譯時(shí)正確,運(yùn)行時(shí)將產(chǎn)生錯(cuò)誤;C、 輸出零;D、 輸出空。22. 下面哪些選項(xiàng)是正確的main 方法說明?A、 public main(String args)B、 public static void main(String args)C、 private

15、static void main(String args)D、 void main()23. 給定下面的代碼片段:1) String str = null;2) if (str != null) && (str.length() > 10) 3) System.out.println("more than 10");4) 5) else if (str != null) & (str.length() < 5) 6) System.out.println("less than 5");7) 8) else System

16、.out.println("end"); 哪些行會(huì)導(dǎo)致錯(cuò)誤?A、 line 1B、line 2C、 line 5D、 line 824. 下面屬于Java線程同步方法的方法有( )A.joiny()C.wait()B.run()D.destroy()25.欲編寫如下圖的一個(gè)界面,用于顯示用戶指定的圖像:如果在區(qū)域A 中只能放置一個(gè)AWT組件,從各組件的本來功能角度考慮,最好使用哪種組件:A、 TextAreaB、 PanelC、 TextFieldD、 Canvas26.界面如上題所示。如果在A 區(qū)域使用某種AWT組件( java.awt.Component負(fù)責(zé)繪制圖像 ,

17、 則繪圖的語句最好應(yīng)放在該組件的哪個(gè)方法中( 考慮到應(yīng)用程序和機(jī)的 AWT線程都會(huì)要求重畫該組件)?A、 構(gòu)造方法B、 paint( Graphics g)C、 update ( Graphics g)D、 repaint()的子類)來Java 虛擬27. 下列哪個(gè)方法可用于創(chuàng)建一個(gè)可運(yùn)行的類( )A.public class X implements Runable public void run(). B.public class X implements Thread public void run(). C.public class X implements Thread public

18、 int run(). D.public class X implements Runable protected void run(). 28. 如果希望所有的控件在界面上均勻排列,應(yīng)使用下列哪種布局管理器()A BoxLayoutB GridLayoutC BorderLayoutD FlowLayout29. 看下面一段程序:class Aclassvoid go()System.out.println("Aclass");public class Bclass extends Aclassvoid goSystem.out.println("Bclass&

19、quot;);public static void main(String args)Aclass a=new Aclass();Aclass a1=new Bclass();a.go();a1.go();以上程序運(yùn)行結(jié)果是:A、 AclassAclassB、 BclassBclassC、 AclassBclassD、 BclassAclass30. 下列關(guān)于 Java 線程的說法那些是正確的()A、 每一個(gè) Java 線程可以看成由代碼、一個(gè)真實(shí)的CPU以及數(shù)據(jù)三部份組成。B、 創(chuàng)建線程的兩種方法中,從Thread 類中繼承的創(chuàng)建方式可以防止出現(xiàn)多父類問題。C、 Thread 類屬于 jav

20、a.util程序包。D、 以上說法無一正確。31. 看以下程序: boolean a=false; boolean b=true;boolean c=(a&&b)&&(!b);int result=c=false?1:2;這段程序執(zhí)行完后,c 與result的值是:A、 c=false;result=1;B、 c=true;result=2;C、 c=true;result=1;D、 c=false;result=2;32. 運(yùn)行下列程序 , 會(huì)產(chǎn)生什么結(jié)果public class X extends Thread implements Runablepubli

21、c void run()System.out.println("this is run()");public static void main(String args)Thread t=newt.start();Thread(new X();A、 in the Inner outerB、 outerC、 in the InnerD、編譯不通過33. 指出下列程序的運(yùn)行結(jié)果int i = 9;switch (i) default:System.out.println("default");case 0:System.out.println("ze

22、ro");break;case 1:System.out.println("one");case 2:System.out.println("two");A、 defaultB、 default, zeroC、 error default clause not definedD、 no output displayed那個(gè)34. 運(yùn)行下列程序,會(huì)產(chǎn)生什么結(jié)果: class Outer1private int a;void foo(double d,final float f) String s;final boolean b;class Inn

23、ervoid methodInner()System.out.println("in the Inner");public static void main(String args)Outer1 me=new Outer1();me.foo(123,123);System.out.println("outer");A、 in the Inner outerB、 outerC、 in the InnerD、 編譯不通過35. 運(yùn)行下列程序的結(jié)果是 ( ) abstract class MineBase abstract void amethod(); st

24、atic int i;public class Mine extends MineBasepublic static void main(String argvint ar=new int 5 ;for(i=0;i System.out.println(ari ) );A.打印 5個(gè)0C.編譯出錯(cuò),Mine應(yīng)聲明為abstractB. 編譯出錯(cuò),數(shù)組ar 必須初始化D. 出現(xiàn) IndexOutOfBoundes的例外36. 要從文件 file.dat文件中讀出第10 個(gè)字節(jié)到變量C 中,下列哪個(gè)方法適合( )A.FileInputStreamin=newFileInputStream(file

25、.dat);in.skip9.;intc=in.read();B.FileInputStreamin=newFileInputStream(file.dat);in.skip10.;intc=in.read();C.FileInputStream in=new FileInputStream(file.dat );int c=in.read();D.RandomAccssFilein=RandomAccssFile( file.dat);in.skip9.;intc=in.readByte();37. 構(gòu)造方法何時(shí)被調(diào)用 ( )A. 類定義時(shí)C.調(diào)用對(duì)象方法時(shí)B. 創(chuàng)建對(duì)象時(shí)D. 使用對(duì)象的變

26、量時(shí)38.下面哪個(gè)修飾符修飾的方法只能被本類中的其他方法使用(A、 protectedB、 staticC、 private)D、public39. 為實(shí)現(xiàn)多線程之間的通信,需要使用下列哪種流才合適()A Filter streamB File streamC Random access streamD Piped stream40. 欲構(gòu)造 ArrayList類的一個(gè)實(shí)例,此類繼承了A、 ArrayList myList=new Object();B、 List myList=new ArrayList();C、 ArrayList myList=new List();D、 List myL

27、ist=new List();List接口,下列哪個(gè)方法是正確的?41. 運(yùn)行下列程序 , 會(huì)產(chǎn)生什么結(jié)果public class X extends Thread implements Runablepublic void run()System.out.println("this is run()");public static void main(String args)Thread t=new Thread(new X();t.start();A、 第一行會(huì)產(chǎn)生編譯錯(cuò)誤B、 第六行會(huì)產(chǎn)生編譯錯(cuò)誤C、 第六行會(huì)產(chǎn)生運(yùn)行錯(cuò)誤D、 程序會(huì)運(yùn)行和啟動(dòng)42.下面哪條語句定義了

28、5 個(gè)元素的數(shù)組()A、 int a=22,23,24,25,12;B、 int a =new int(5);C、 int 5 array;D、 int arr;43、數(shù)組中可以包含什么類型的元素?A、 int 型 B 、 string 型 C 、 數(shù)組_。D、 以上都可以44.給出一段程序,選擇運(yùn)行結(jié)果(public class sss public static void main(String args))String s1=args1;String s2=args2;String s3=args3;String s4=args4;System.out.println(“ args2=”

29、 +s2);命令行執(zhí)行:A、 args2=2java sss 1 2 3 4結(jié)果是下面哪一個(gè)?B、 args2=nullC、 args2=1D、運(yùn)行出現(xiàn)異常45. 類 Teacher 和 Student 是類 Person 的子類; Person p;Teacher t; Student s;/p, t and s are all non-null.if(t instanceof Person) s = (Student)t; 最后一句語句的結(jié)果是:A、 將構(gòu)造一個(gè)Student 對(duì)象;B、 表達(dá)式是合法的;C、 表達(dá)式是錯(cuò)誤的;D、 編譯時(shí)正確,但運(yùn)行時(shí)錯(cuò)誤。46.給出一段程序,試判斷哪個(gè)是正確的結(jié)果(public class rtExceptpublic static void throwit()System.out.print(“ throwit” );throw new RuntimeException(); public static void main(String aa)try)System.out.print(“ hello“ );throwit(); catch(Exception re)System.out.print(“ caught” ); finallySystem.out.print(“ finally” ); S

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論