


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、Java東華理學(xué)試卷及答案東華理學(xué)2012 2013 學(xué)年第1 學(xué)期考試試卷Java程序設(shè)計課程閉課程類別:考查A1 選擇題(共35分)WhatisofJavasourceA、.javaB、C、.txtD、.extWhichcommandcancompileJavasourcecode?DA、editB、dirC、java D、WhichidentifiesisillegalC)? A、$_$123C、some*name D、you_can_alWhichconversionisillegalB-128-127 A、shortx=1000;B、bytex=1000;C、byte x=100;D
2、、float x=12L; examplestatic void main(String argsboolean b;b = (2 3) & (3 2);System.out.print(b = +b); b = false | true ;System.out.println(b = +b); What is the result?( A )A、b=falseb=true B、b=truebfalse C、b=truebtrueD、b= false b= false6. class example publicstaticvoidmain(Stringargs) inti=1;ai+=ai+
3、2;System.out.println(ai+); What is the result?( C)A,4B,5C3,D,6classExample String str=new String(good); charch=a,b,c;publicstaticvoidmain(Stringargs) Example ex=new Example(); ex.change(ex.str,ex.ch);System.out.print(ex.str+ and ); Sytem.out.print(ex.ch); public void change(String str,char ch) str=t
4、est ok;ch0=g;Whatistheresult?(D) A good andabcBgoodandgbc Ctestokandabc DtestokandgbcSetx=1,y=2,z=3,expression:y+=z-/+xwhatisresult(A) A3B 3.5C4D5what is result (A)? classexamplestatic int a=3;public static void main(String args) new example().a+;new example().a+=2; A6B7C4D51.class X (D)public stati
5、c void main(Stringargs)String s1=newString(“true”);Boolean b1=newBoolean(true);if(s1.equals(b1)System.out.println(“equal”);A the program runs and printsnothing B the program runs and prints “equal”C An error at line 5 causes compilation to failD The program runs but aborts with an exception 11.1.int
6、erface Ainta=3;void4.class B implementAvoidshow()public static void main(Stringargs)System.out.println(a+);Whichlinesareincorrectwhenthecodeiscompiled?(C) A 57B 68C 5 6 8D 5 6classAinta=2;class B extendsA inta=3;class testpublic static void main(String args)Ag=newB();不能把類的東西給類System.out.println(g.a)
7、;Whatisresult?(B) A2B no resultC1D3whatisresult(A) classApublicstaticvoidmain(Stringargs) tryint a=1/0; int b=1,2; b4=4;catch(ArrayIndexOutOfBoundsException e) System.out.print(vvv);catch(ArithmeticException e)/算法異常System.out.print(rrr);finally System.out.println(sss); A rrrvvv B rrrsss C Dsssrrrcla
8、ssAfinal int i4=(int)(Math.random()*20); static final int i5=(int)(Math.random()*20); public void print() System.out.println(i4=+i4+i5=+i5); public static void main(String args)Ag1=newA(); g1.print();Ag2=newA(); g2.print();Assumei4=15i5=16wheng1.print()methodisexecuted.whatresultisdisplayedwheng2.pr
9、int()isexecuted(A) A 1516B1517C 1814D 1515classAvoid f(int x)System.out.println(x); void f(long x)System.out.println(x); public static void main(String args) A g1= newA();g1.f(5.6); What is result( D ) A 5.6B 5C 6D error、翻譯題20分,每題5分1)Encapsulation(封裝the mechanism(進(jìn)程;途徑binds(約束)together code and the
10、data it manipulates(操縱;操作and keep both safe from outside 擾misuse(濫2)Encapsulationallowsanobjecttoseparate itsinterfacefromitsimplementationThedataandtheimplementationcodefortheobjectarehiddenbehinditsinterfaceSoencapsulationhidesinternalimplementationdetailsfromusers.Thepowerofencapsulatedcodeisthat
11、everyoneknows howtoaccessitandthuscanuseitregardlessoftheimplementationdetailsandwithoutfearofunexpectedsideeffects.3)InJavathebasisofencapsulationistheclass.Aclassdefinesthestructureandbehavior(dataandcode)thatwillbe shared by a set of objects. Each object of a given class contains the structure an
12、dbehaviordefinedbytheclass,asifitwerestampedoutbyamoldintheshapeoftheclass.Forthisreason,objectsaresometimes referredto asinstance ofclass. Thus,a class isa logicalconstruct; anobject has physicalreality.在Java基礎(chǔ)類的封裝。個類定義的結(jié)構(gòu)和為(數(shù)據(jù)和代碼),將由組對象的共享。每個對象的個給定的類包含類定ft,類是種邏輯結(jié)4)Whenyoucreateaclass,youwillspecif
13、ythecodeanddatathatconstitutethatclass.Collectively, theseelementsarecalledmembersoftheclass.Specificallythecodethatoperatesonthatdataisreferredtoasmembervariables or instancevariables.三程序閱讀題(每題4分,共計20分):Theresultoffollowingprogram35java.io.*; public class UseLabel public static void main(String arg
14、s)Loop:for(int i=2; i10; i+) for(int j=2;jif(i%j=0)continueLoop;System.out.print(i+ ); Theresultoffollowingprogramis:(1248) importjava.io.*;public class Class1 publicstaticvoidmain(Stringargs) inti,ax,in;int a =12,67,8,98,23,56,124,55,99,100);ax= in=a0; for(i=1; iif( ai ax) ax = ai;System.out.printl
15、naxin)/ 循環(huán)外,后的程序會覆蓋前輸出的程序System.out.println();The result of following program is(a=12 a=1b=false ch=A)class Aint a;A() a=1 ;A(int b)a=b;void show() System.out.println(“a=”+a);public class Class1public static void main (String args) A a1=new A(12);A a2=new A(); a1.show();a2.show(); boolean b=false; c
16、har ch=65;System.out.println(“b=”+b+”tch=”+ch);The result of followingprogramis:x inA:54 xisB:32class A intx;void print() System.out.println(x inA:+x);class B extends A int x;void output() x=32;super.x=54; print();System.out.println(x is B:+x);public class HideFields public static void main(String a
17、rgs) B b=new B();b.output();The result of following program is:出現(xiàn)被0除的異常情況除數(shù)=9被除數(shù)=0java程序運結(jié)束! public class ArithmeticException public static void main(String args)int a,b,c; trya=9; b=0;c=a/b; System.out.println(a+/+b+=+c);catch(ArithmeticException e) System.out.println(出現(xiàn)被0除的異常情況); finallySystem.out.println(除數(shù)=+a); System.out.println(被除數(shù)=+b);System.out.println(java程序運結(jié)束! );四、編程題25分1eamhcastero,eeotdeeo. 0public class test1public static void main(String args) int a;byte b; byte c;doublea1=9.5; doubleb1=8.5; intc1=2;a=Integer.parseInt(a1);b=B
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 愛麗絲漫游奇境記故事深度解讀與賞析
- 2025年湖北武漢中考模擬英語試卷試題及答案
- 厲行節(jié)約反對浪費的心得及感悟(28篇)
- 2024年初一教師學(xué)期工作總結(jié)(3篇)
- 2025年教案設(shè)計:鐘聲叮叮當(dāng)教學(xué)的實踐與探索
- 安全法律知識培訓(xùn)課件
- 道路運輸企業(yè)安全評價
- 基坑支護(hù)工程分包勞務(wù)合同
- 瀝青混凝土采購合同
- 寫作技巧提升指南
- DB11 489-2016 建筑基坑支護(hù)技術(shù)規(guī)程
- 2022年江蘇農(nóng)林職業(yè)技術(shù)學(xué)院職業(yè)適應(yīng)性測試題庫及答案解析
- 2022年安全生產(chǎn)費用投入臺賬(模版報表)
- 供水設(shè)施水池基礎(chǔ)土石方開挖施工組織方案
- 《魚類的骨骼系統(tǒng)》
- 車輛工程畢業(yè)設(shè)計(論文)-電動叉車設(shè)計
- 《建筑識圖》匯總題庫(學(xué)生用)
- 印刷制品QC工程圖
- 傳感器及檢測技術(shù)教案
- 手工焊錫知識
- 《采油工程》講義
評論
0/150
提交評論