




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
XX大學2008-2009學年第(一)學期考試試卷課程代碼 課程名稱面向對象程序設計A(JAVA)考試時間120分鐘題號一二三四五總成績得分I 閱卷教師簽字: B卷I:注意事項:I1.答題前,請先在試卷和機讀卡上對應位置用鋼筆準確清楚的填寫上本人姓名和學號,i 機讀卡的科目欄里填寫年級和專業的簡稱,并用 2B鉛筆填涂學號(必須填在前8| 列,剩最右邊的一列不填涂);i2.試卷答案必須用2B鉛筆在機讀卡上按對應題號準確、清楚涂寫,答在試卷上無效;I 本試卷共65個小題,1~60小題填寫在機讀卡上,按【1】~【60】的編號順序涂寫。61~65■題做在答題卷上。【1】~【40】每題1分,【41】~【60】每題2分。【61】~【65】每題4線:分,做在答題卷上,共100分。訂一、判斷題(本大題共10小題,每小題1分,共10分,正確的填A,錯誤的填B)封1.數組、類和接口都是引用數據類型。密!2.Java語言中一個char類型的數據占用2個字節大小的內存空間。編譯語句〃。瀝ZeaDouble=33.5D;時不會出現編譯錯誤。程序中拋出異常時知ow…),只能拋出自己定義的異常對象。:5.所有的文件輸入/輸出流都繼承于InputStream類/OutputStream類。6.一個異常處理中的“緲語句可以有多個。I7.Applet程序不能單獨運行,需要嵌入在HTML文件中,借助瀏覽器來解釋執行。8.Java語言在設計員程序時,應注意在服務器端使用0命。1類來處理客戶端的連接請求。I9.數組是用來存放一批相同類型的對象或數據,當數據的順序和個數經常發生變動時就要用到向量來: 存放。10. 構造函數不能被重載。二、單項選擇題(本大題共30小題,每小題1分,共30分)I 在每小題列出的四個選項中,只有一個是符合題目要求的,請將其代碼填在后面的I答題卷上。錯選或未選均無分。訂11. 下列哪個屬于容器的構件?裝 A)JFrameB)JButtonC)JPnel D)JApplet封12. 如果希望所有的控件在界面上均勻排列,應使用下列那種布局管理器?密、 、 、A) BoxLayout B)GridLayoutC)BorderLayoutD)FlowLouLayout!13. Java語言具有許多優點和特點,下列選項中,哪個反映了Java程序并行機制的特點?A)安全性B)多線性 C)跨平臺D)可移植I14.14.JavaApplication與Applet所用編譯命令相同通常情況下JavaApplication只能有一個main()方法JavaApplet必須有HTML文件才能運行JavaApplet程序的class文件可用java命令運行下列事件監聽器中,無法對TextField對象進行事件監聽和處理的是ActionListener B)FacusListenerC)MouseMotionListenerD)ChangeListener下列關于Applet的安全限制敘述中,錯誤的是通常情況下,禁止Applet讀寫本地文件系統通常情況下,禁止Applet向Applet源主機之外的任何主機建立網絡連接通常情況下,禁止pplet讀取系統信息通常情況下,禁止Applet加載本地庫或方法下列標識符(名字)命名原則中,正確的是類名的首字母小寫 B)變量和方法名的首寫字母大寫C)接口名的首寫字母小寫 D)常量完全大寫作為Java應用程序圖形界面基礎的是—。Panel B)FrameC)WindowsD)AppletJava不允許多重繼承,而利用的設計來達到多重繼承的目的。A)類B)接口C)對象D)方法下列哪個選項是合法的標識符?123B)__name C)class D)1first下列關于for循環和while循環的說法中哪個是正確的?while循環能實現的操作,for循環也都能實現while循環判斷條件一般是程序結果,for循環判斷條件一般是非程序結果兩種循環任何時候都可替換〃)兩種循環結構中都必須有循環體,循環體不能為空下列關于Java語言特點的敘述中,錯誤的是A)Java是面向過程的編程語言 B)Java支持分布式計算C)Java是跨平臺的編程語言 D)Java支持多線程下列的哪個賦值語句是不正確的?floatf=11.1;B)doubled=5.3E12;C)floatd=3.14f;D)doublef=11.1E10f;下列的哪個賦值語句是正確的?chara=12;B)inta=12.0;C)inta=12.0f; D)inta=(int)12.0;下列哪個修飾符可以使在一個類中定義的成員變量只能被同一包中的類訪問?A)private B)無修飾符 C)public D)protected在Applet的關鍵方法中,下列哪個方法是關閉瀏覽器以釋放Applet占用的所有資源?A)init() B)start() C)paint() D)destroy()給出下列代碼,則數組初始化中哪項是不正確的?byte[]array1,array2[];bytearray3[][];byte[][]array4;A)array2=array1B)array2=array3C)array2=array4D)array3=array4下列關于內部類的說法不正確的是內部類的類名只能在定義它的類或程序段中或在表達式內部匿名使用內部類可以使用它所在類的靜態成員變量和實例成員變量內部類不可以用瀝、"£修飾符定義為抽象類內部類可作為其他類的成員,而且可訪問它所在類的成員順序執行下列程序語句后,則b的值是Stringa="Hello";Stringb=a.substring(0,2);Hello B)hello C)Hel D)null下列常見的系統定義的異常中,哪個是輸入、輸出異常?A)ClassNotFoundException B)lOExceptionC)FileNotFoundException D)UnknownHostException下列哪個選項是正確計算42度(角度)的余弦值?A)doubled=Math.cos(42); B)doubled=Math.cosine(42);C)doubled=Math.cos(Math.toRadians(42));D)doubled=Math.cos(Math.toDegrees(42));WhichisJavakeyword?A)math B)nullC)FALSE D)TRUEWhichistherangeofinttype?A)-216?216-1 B)-231-231-1C)-232?232-1 D)-264?264-1FilterOutputStreamistheparentclassforBufferedOutputStream,DataOutputStreamandPrintStream.WhichclassesarevalidargumentfortheconstructorofaFilterOutputStream?A)InputStreamB)OutputStreamC)FileD)RandomAccessFileWhichofthefollowingarevaliddeclarations?A)charc='\r'B)charc="cafe"C)charc='0xfg'D)charc="\xef"Whichstatementaboutthegarbagecollectionmechanismaretrue?Garbagecollectionrequireadditionalprogramecodeincaseswheremultiplethreadsarerunning.Thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.TheprogrammerhasamechanismthatexplicityandimmediatelyfreesthememoryusedbyJavaobjects.ThegarbagecollectionmechanismcanfreethememoryusedbyJavaObjectatexplectiontime.Whichofthefollowingistrueofanonymousinnerclass?Anonymousinnerclasscanbedeclaredasprivate,protectedorpublic.Anonymousinnerclasscanimplementmultipleinterfaces.ifnotextendedorimplemented,ananonymousinnerclasscanbecomeimmediatesubclassoftheouterclassorimplementaninterface.ifnotextendedorimplemented,ananonymousinnerclasscanbecomeimmediatesubclassofouterclassorimplementmutipleinterfaces.38.Whichstatementistrueaboutaninnerclass?ItmustbeanonymousItcanimplementaninterfaceItisonlyaccessibleintheenclosingclassItcanaccessanyfinalvariablesinanyenclosingscope.39.Whichisthemain()methodreturnofaapplication?第3頁共9頁(B卷)A)String B)byteC)char D)voidWhichiscorrectedargumentofmain()methodofapplication?A)Stringargs B)Stringargs[]C)Charargs[][]D)StringBufferarg[]三、單項選擇題(本大題共20小題,每小題2分,共40分)在每小題列出的四個選項中,只有一個是符合題目要求的,請將其代碼填在后面的答題卷上。錯選或未選均無分。閱讀下面代碼if(x==0)(System.out.println(“冠軍”);}elseif(x>-3)(System.out.println(“季軍”);}若要求打印字符串“季軍”,則變量X的取值范圍是A)x!=0&&x>-3B)x=0 C)x>-3||x!=0D)x<=-3假設Foo類有如下定義,設f是Foo類的一個實例,下列語句調用哪個是錯誤的?publicclassFoo(inti;staticStrings;voidimethod()(}staticvoidsmethod()(}}A)Foo.imethod();B)f.imethod();C)System.out.println(f.i);D)Foo.smethod();給出下列代碼,如何使成員變量m被方法fun()直接訪問?classTest{privateintm;publicstaticvoidfun(){}}將privateintm改為protectedintm將privateintm改為publicintm將privateintm改為staticintm將privateintm改為intm以下程序運行后的輸出結果是:classStaticStuff{staticintx;static{x+=5;}publicstaticvoidmain(String[]args){System.out.println("x="+x);}static{x%=3;}}A)x=0B)x=5C)x=3D)x=2閱讀下面程序importjava.*;publicclassTypeTransition{publicstaticvoidmain(Stringargs[]){chara='E';
intm=100;intj=97;intaa=a+m;System.out.println("aa="+aa);charbb=(char)j;System.out.println("bb="+bb);}}如果輸出結果的第二行為bb=a,那么第一行的輸出是A)aa=100B)aa=169C)aa=97D)aa=69下列哪個選項的java源文件代碼片段是不正確的?A)A)packagetestpackage;publicclassTest{}C)importjava.io.*;classPerson{}publicclassTest{}importjava.io.*;packagetestpackage;publicclassTest{}importjava.io.*;importjava.awt.*;publicclassTest{}Giventhefollowingclassdefinition:classA{protectedinti;A(inti){this.i=i;}}whichofthefollowingwouldbeavalidinnerclassforthisclass?A)classB{} B)classBextendsA{}classBextendsA{ D)classB{B(){System.out.println(“i=”i);}classA{}}publicclassHappy{publicstaticvoidmain(Stringargs[]){inti=4;intj=2;methodA(i,j);System.out.println(i);}staticpublicvoidmethodA(inti,intj){i<<=j;}}A)compilationerrorB)16 C)64 D)449.Givethefollowingjavasourcefragment://pointxpublicclassInteresting{//dosomething}WhichstatementiscorrectlyJavasyntaxatpointx?A)importjava.awt.*; B)packagemypackageC)staticintPI=3.14 D)publicclassMyClass(//dootherthing...}Givethefollowingjavaclass:publicclassExample(staticintx[]=newint[15];publicstaticvoidmain(Stringargs[])(System.out.println(x[5]);}}Whichstatementiscorrected?A)Whencompile,someerrorwilloccur. B)Whenrun,someerrorwilloccur.C)Outputiszero. D)Outputisnull.Whatiswrittentothestandardoutputgiventhefollowingstatement:System.out.println(4&7);Selecttherightanswer:A)4B)5C)6D)7Whatiswrittentothestandardoutputgiventhefollowingstatement:System.out.println(7l9);Selecttherightanswer:A)0B)7C)9D)15Looktheinheritancerelation:personman womanInasourceofjavahavethefollowingline:womanw=newman():Whatstatementarecorrected?A)Theexpressionisillegal. B)Compilecorrectedbutrunningwrong.C)Theexpressionislegal. D)Willconstructawomanobject.WhichcanNOTbeusedindeclaringordeclaringandinitializinganautomatic(methodlocal)variable?A)final B)staticC)expressionsD)Constantsofnon-primitivetypeWhichstatementsistrueaboutListeners?AtmostonelistenercanbeaddedtoanysimpleComponent.ThereturnvaluefromalistenerisusedtocontroltheinvocationofotherlistenerIfmultiplelistenersareaddedtoasinglecomponent,theymustallbemadefriendstoeachotherIfmultiplelistenersareaddedtosinglecomponent,theorderofinvocationofthelistenerisnotspecifieD)Floats=newFloat(0.9F);Floatt=newFloat(0.9F);Doubleu=newDouble(0.9);Whichexpression'sresultistrue?A)s!=t B)s.equals(t) C)s==u D)t.equals(u)Givethefollowingmethod:publicvoidmethod()(Stringx,y;x=newString(“helloworld”);y=newString(“gameover”);System.out.println(x+y+"ok'');x=null;x=y;System.out.println(x);}Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectxreferedisdefinitelyelibiletobegarbagecollection.beforeline5beforeline6beforeline7Beforeline9Giventhefollowingclassoutline:classExample(privateintx;//restofclassbodypublicstaticvoidmain(Stringargs[])(//implementationofmainmethod}}Whichstatementistrue?A)x=2isavalidassignmentinthemain()methodofclassExample.B)Changingprivateintxtostaticintxwouldmakex=2avalidassignmentinthemain()methodofclassExample.Changingprivateintxtopublicintxwouldmakex=2avalidassignmentinthemain()methodofclassExample.Changingprivateintxtointxwouldmakex=2avalidassignmentinthemain()methodofclassExample.Givefollowingprograme:classEX(publicstaticvoidmain(Stringargs[])(outer:for(inti=0;i<3;i++)inner:for(intj=0;j<3;j++)(if(j>=1)breakouter;System.out.println(j+"and"+i);}}}Whichwillbeoutput?A)0and0B)0and1C)0and2D)0and3Whatwillbetheresultofattemptingtocompileandrunthefollowingcode?abstractclassMineBase(abstractvoidamethod();staticinti;}publicclassMineextendsMineBase(publicstaticvoidmain(Stringargs[])(int[]ar=newint[5];for(i=0;i<ar.length;i++)System.out.println(ar[i]);}}A)asequenceof50’swillbeprinted B)Error:arisusedbeforeitisinitializedC)ErrorMinemustbedeclaredabstract D)IndexOutOfBoundesError四、閱讀以下程序,寫出運行結果或功能(本大題共5小題,每小題4分,共20分)importjava.io.*;publicclassTest1(publicstaticvoidmain(String[]args)(Loop:for(inti=1;i<15;i++){if(i%3!=0)continueLoop;System.out.printf(i+"");}}}Whatwillbetheoutput?36912importjava.io.*;publicclassTest{publicstaticvoidmain(String
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025版租賃住宅合同
- 2024年隴南市市屬事業單位考試真題
- 二年級上冊數學教案-總復習3|北師大版
- 2024年合肥長豐縣水湖鎮招聘城市管理執法輔助人員真題
- 2024年甘肅人力資源服務股份有限公司招聘真題
- 農村建房安裝合同范本
- 廢除的設計合同范本
- 地理西亞第1課時課件-2024-2025學年七年級地理下學期(人教版2024)
- 修理電機勞務合同范本
- 藝術班轉讓合同范本
- 平面向量在三角函數中的應用(學案)
- 中藥的道地藥材課件
- 《跋傅給事帖》2020年浙江嘉興中考文言文閱讀真題(含答案與翻譯)
- 幼兒園《3-6歲兒童學習與發展指南》健康領域知識試題及答案
- 國家職業技能標準 (2021年版) 嬰幼兒發展引導員
- 幼兒園小班科學:《小雞和小鴨》 PPT課件
- 伯努利方程-ppt課件
- 年產20噸阿齊沙坦原料藥生產車間的設計和實現材料學專業
- 電子公章模板
- 第3章軌道車輛牽引計算
- 基于JSP的校園網站的設計與實現論文
評論
0/150
提交評論