版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、.華南農(nóng)業(yè)大學期末考試試卷( b卷)2008-2009學年第 2 學期考試科目:面向?qū)ο蟪绦蛟O(shè)計考試類型:(閉卷)考試時間:120分鐘學號姓名年級專業(yè)_題號一二三四五總分得分評閱人一、選擇題( 30分)說明:每題2 分,只有1 個正確答案,請將正確答案填寫在下面表格中。題號123456789101112131415答案1 which of the following statements is correct about java packages?a. a package may contain unlimited number of nested sub-packages.b. a pac
2、kage is a collection of related java source program.c. using the import statement can include all the classes into the current program from a specified package and its sub-packages.d. if there is no package statement used, the current class will not be in any package. 2 which one is the wrong statem
3、ent about java constructors?a.the name of a constructor must be the same as its classs name.b.a constructor has no return value and can not be modified byvoid .c. a constructor of the parent class can not be inherited by its sub-classes.d. all constructors must be modified bypublic.3 giving the code
4、 bellow:class testprivate int m;public static void fun() /* some code. */ how to make the member variable maccessible for method fun()?a.change private int m to protected int mb.change private int m to public int m.c. change private int m to static int md. change private int m to int m 4 whichofthef
5、ollowingfunctionsisanoverloadingfunctionof publicvoidexample().?a. public void example().b. public int example().c. public void example2().d. public int example(int m, float f).5 in java, a class may have many different methods with the same name. the number, type,sequences of arguments in these met
6、hods are different, and the return value can be different as well. what do we call this feature in terms of object-oriented programming?a.hidingb.overridingc. overloadingd. this feature is not supported in java6 how to execute the following program?public class testpublic static void main(string arg
7、s) system.out.println(args0);a.java test.classb.java testc. java test astringd. javac test7 if a container has been resized, which of the following layout manager did not change the internal components size?a.cardlayoutb.flowlayoutc. borderlayoutd. gridlayout8 which is the right statement about exce
8、ption handling?a. in java, all exceptions are necessary to be caught and handled.b. the “catch ”statement catches exception by type-matching.c. in the “try-catch-finally ”structure, the program will exit after exception handling.d. exception is a kind of errors, and it should be absolutely avoided i
9、n programs.9 the following statements are about type-casting, which one is correct?a. a reference variable of a class can only be assigned to an object of its first level sub-classes of this class.b. an object can not be casted to the type of another class which has no inheritance.relationship with
10、the object s original class.c. a child class s reference variable can be assigned to an object of its parent class.d. there is only explicit casting, but no implicit casting.10 both class teacher and student are the sub-classes of person . person p; teacher t; student s; / assume p, t and s are not
11、null if(t instanceof person) s = (student)t; which statement about the last line of expression is correct?a. a new student object will be created.b. the type-casting is correct.c. the expression is incorrect.d. there is no syntax error but will generate runtime error.11 according to the code below,
12、which statement is correct?public class test static object o;public static void main(string args) system.out.println(o);a. generates compile error.b. compiles ok, but has runtime errors.c. outputs zero.d. outputs “null ”.12 according to the code below, select the statement which is false.string s =
13、hello;string s1 = new string(hello);string s2 = ern();string s3 = hello;a.s1 = sb.s2= sc.s = s3d.s2= s313 the array definition code is given below, which statement is correct?string s = new string10;a.the definition of arrays is illegal in syntax.b. s is a 10 10two-dimensional array.c. all ele
14、ments in s are .d. s is an array of ten arrays.14 which is the correct output according to the program given bellow?public static void main(string args)scanner scanner = new scanner(this is one that is two); scanner.usedelimiter( is); / there is a space before is.while(scanner.hasnext() system.out.p
15、rint(scanner.next();a.this one that twob.th one that twoc. thone that twod. this is one that is two15 the file “empty.txt”does not exist before, what its content will be after executing thefollowing code.public static void main(string args) throws filenotfoundexception printwriter pr = new printwrit
16、er(new file(empty.txt);pr.print(onettwo);pr.append(n1t2);pr.close();a.one twob.onettwo121t2c. onettwon1t2d. one two 1 2二、改錯題(20 分)說明:寫出每段代碼的錯誤原因并改正錯誤,每小題4 分,說明原因和改正各2 分。1 class first import java.io.*;package mypackage;class second 2 class a string name;public a(string s) name = s; class b extends a
17、int id;public b (int i) id = i; 3 class alpha private void m() .public void p() class beta extends alpha public void m() private void p() 4 interface base void m();void n();class child implements base public void m() system.out.println(this is method m);5 public class b extends a final void increase
18、() value += 2;class a int value = 0;final void increase() value += 1;三、程序閱讀題(20 分)說明:閱讀下面程序并寫出它們的輸出結(jié)果,每小題5 分。1 the program is as below:.class aint h = 1;public a(int h)h = h;system.out.println(this.h);this.h = h;system.out.println(this.h);public static void main(string args)a a = new a(2);2 the prog
19、ram is as below:class base public base() system.out.println(what a pleasure!);public base(string s) this();system.out.println(i am + s + !);public class child extends basepublic static void main(string args) child t = new child(mike);public child(string s) super(s);system.out.println(how do you do?)
20、;public child() this(i am tom);.3 the program is as below:class divtest public static void main(string args) int r, n, d;n = 10; d = 0;try r = n / d;system.out.println(r= + r); catch(arithmeticexception e) system.out.println(divide 0 exception!); finally system.out.println(calculation complete!);sys
21、tem.out.println(program finish!);4 analyze the program bellow, and explain its effect.public class myframe extends jframe jbutton b1, b2;public myframe() actionlistener a = new actionlistener() public void actionperformed(actionevent evt) if (evt.getsource() = b1) b1.setenabled(false);b2.setenabled(
22、true); else b1.setenabled(true);b2.setenabled(false);setlayout(new flowlayout();b1 = new jbutton(1); b1.addactionlistener(a); add(b1);b2 = new jbutton(2); b2.addactionlistener(a); add(b2); setdefaultcloseoperation(jframe.exit_on_close);.setsize(150, 100);setvisible(true);public static void main(stri
23、ng args) new myframe();四、應(yīng)用設(shè)計題(6 分)the following classes are a part of the classes founded in a companys personnel management system, find out their relationships and illustrate using a uml class diagram.employee, long-tern employee, temporal employee, manager, temporal salesman.五、程序設(shè)計題(24 分)說明:按照題目
24、要求編寫下面兩段程序。1write a java application program containing these classes:person , student , teststudent.the details are: class person properties name: string sex: charid : stringphone: stringemail : string methodsperson(name name, char sex, string id): constructorstring getid()void setemail(string emai
25、l)void setphone(string phone)string tostring(): outputs a persons informationclass studenta sub-class derived from person, more properties are added:propertiessno: longsclass : stringmethodsstudent(long sno, string name, char sex, string id): constructorsetclass(string sclass)string tostring(): outp
26、uts a students information class teststudenta class used as the main class to test the functions.use the following information to create a student object,astudent .name:guo yangsex:maleid:22033198807070333sno.:2004002 set other information to astudent . e-mail: phone:88078549output all the information ofastudent .2 calculate the sum ar
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年水產(chǎn)養(yǎng)殖病害防控策略指南
- 2026青海西寧市城北區(qū)大堡子鎮(zhèn)中心衛(wèi)生院招聘衛(wèi)生專業(yè)技術(shù)人員的1人備考題庫含答案詳解
- 2026浙江寧波市鎮(zhèn)海中學國際部誠招學科雙語教師備考題庫及完整答案詳解1套
- 2026年林下經(jīng)濟模式創(chuàng)新發(fā)展課
- 軟件開發(fā)大數(shù)據(jù)模塊開發(fā)規(guī)范手冊
- 2026福建三明市永安市羅坊鄉(xiāng)人民政府招聘編外聘用駕駛員1人備考題庫及完整答案詳解1套
- 2026年企業(yè)并購法律盡調(diào)實務(wù)培訓
- 職業(yè)健康促進與企業(yè)健康管理未來趨勢
- 駐馬店2025年河南駐馬店市平輿縣人民醫(yī)院招聘人事代理人員28人筆試歷年參考題庫附帶答案詳解
- 金華2025年浙江金華義烏市人民檢察院司法雇員招錄6人筆試歷年參考題庫附帶答案詳解
- 江蘇省鹽城市大豐區(qū)四校聯(lián)考2025-2026學年七年級上學期12月月考歷史試卷(含答案)
- 事業(yè)編退休報告申請書
- 原發(fā)性骨髓纖維化2026
- 半導(dǎo)體廠務(wù)項目工程管理 課件 項目6 凈化室系統(tǒng)的設(shè)計與維護
- 河南省洛陽強基聯(lián)盟2025-2026學年高二上學期1月月考英語試題含答案
- 2026年中考數(shù)學模擬試卷試題匯編-尺規(guī)作圖
- 安全技術(shù)勞動保護措施管理規(guī)定
- 新建加油站可行性研究報告6118933
- 論高級管理人員應(yīng)具備的財務(wù)知識
- GB/T 7354-2003局部放電測量
- GB/T 1690-1992硫化橡膠耐液體試驗方法
評論
0/150
提交評論