




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、樹(shù)德科技大學(xué)資訊工程系九十七學(xué)年度第二學(xué)期Java3程式設(shè)計(jì)筆試考試題學(xué)號(hào): 姓名: (98/04/06)請(qǐng)同學(xué)依照程式輸出格式寫(xiě)出答案,並將答案寫(xiě)在答案欄中,否則不予記分題目答案欄1.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%) class Test int x = 3;void show() System.out.pri ntln (x = + x);public class Test_1 public static void main( Stri ng argv)Test a,b,c;a = new Test();b = new Test();c = b;c.x = 10;System.out.pri nt
2、(a.); a.show();System.out.pri nt(b.); b.show();System.out.pri nt(c.); c.show();1.Ans:a. x = 3b. x = 10c. x = 102.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%)class Car double gas;double eff;double move(double dista nee) if (gas = dista nce/eff ) gas -= dista nce/eff; retur n dista nee;else dista nee = gas * eff;gas = 0;retur n dist
3、a nee;public class Test_2 public static void main(String argv) Car oldcar = new Car(); oldcar.gas = 10.0;oldcar.eff = 25.8;System.out.println(行駛了 +oldcar.move(5000) + 公里);2.Ans:行駛了 258.0 公里3.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%) class TestA int x = 3;void show() System.out.pri ntln (x = + x);class TestB void cha ngeTestA(Te
4、stA t,i nt n ewX) t.x = n ewX;public class Test_3public static void main(String argv)TestA a = new TestA();TestB b = new TestB();a. show();b. cha ngeTestA(a,20);a.show();3.Ans:x = 3x = 204.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%) public class Test_4 public static void main(String argv) int x = 1;int y = 20;int z = 300;System.o
5、ut.pri ntln (x = + x); System.out.pri ntln (y = + y); System.out.pri ntln (z = + z); System.out.pri ntl n();int z = 40;System.out.pri ntl n(x = + x); System.out.pri ntl n(y = + y);System.out.pri ntl n(z = + z); System.out.pr intln ();int y = 2;int z = 3;System.out.pri ntln (x = + x);System.out.pri n
6、tln (y = + y);System.out.pri ntln (z = + z);4.Ans:x = 1y = 20z = 300x = 1Y = 20z = 40x = 1y = 2z = 35.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%)class Mathematics int funny_n um(i nt n) if(n = 2) return 1; returnfunny_num(n- 1) + funny_num(n- 2);public class Test_5 public static void main(String argv) Mathematics m = new Mathemat
7、ics。;System.out.pri ntl n( m.fu nny_n um(6);5.Ans:86.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%) class Point private double x,y;public void setx(double x) this.x = x;public void sety(double y) this.y = y;public String toString() return 圓心座標(biāo):(+ x + , + y + );public Poin t(double x,double y) this.x = x;this.y = y;public Point() x =
8、 y = 0;public Poi nt(Poi nt p) x = p.x;y = p.y;class Circle private Point p;private double r;public Point getp() return new Poi nt(p);Circle(double x,double y,double r) p = new Poi nt(x,y); this.r = r;Circle() this(0,0,1);public String toString() return p.toStri ng() + 半徑:+ r;public class HidePrivat
9、eMember public static void main(String argv) Circle c = new Circle(5,4,3);Point p = c.getp();p.setx(4) ;p.sety(2);System.out.pri ntln( c);System.out.pri ntl n( p);6.Ans:圓心座標(biāo):(5.0,4.0)半徑:3.0圓心座標(biāo):(4.0,2.0)7.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%)7.class TestA Ans:int i =5; void show() i+;i = 6i = 12System.out.pri ntln (i = + i)
10、; class TestB i = 9i = 10int i=4;void cha ngeTestA(TestA t,i nt n ewi) i += n ewi;t.i+=3;System.out.pri ntln (i = + i);System.out.pri ntl n(i = + t.i); public class PassRefere nee public static void main(String argv)TestA a = new TestA(); TestB b = new TestB();a. show();b. cha ngeTestA(a,8);a.show()
11、;8.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%)8.class Clock Ans.private int hr; private int min;w1 時(shí)間 10:10 w2時(shí)間9:20Clock(i nt hr, i nt min)this.hr=hr;this.mi n=mi n;Clock() this(10,10);public String toString() return hr +:+ min; public class CallByThis public static void main( Str in g argv) Clock w1 = new Clock();Clock w2 =new
12、Clock(9,20);System.out.pri ntl n( w1時(shí)間+ w1 );System.out.pri ntln( w2 時(shí)間“ + w2 );9.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%) class Test public int x=50;public static int y;static y=60;public Test() public Test(i nt x) this.x = x;public Test(i nt x, int y) this.x = x;this.y = y;public String toString() return (x,y):( + x + , + y
13、+ );public class Classvar public static void main(String argv)Test a = new Test();System.out.println(物件 a + a);Test b = new Test(100,80);System.out.println(物件 b + b);Test.y = 70;Test c = new Test(200);System.out.println(物件 c + c);9.Ans:物件 a(x,y):(50,60) 物件 b(x,y):(100,80) 物件 c(x,y):(200,70)10.請(qǐng)寫(xiě)出執(zhí)行結(jié)果(10%)class Test int x = 10;int y = 20;Test(i nt x,i nt y) this(y);this.x = x;Test(i nt y) this.y = y;public class Callbythispublic static void main(String argv)Test
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 學(xué)校電教室管理制度
- 學(xué)校請(qǐng)銷假管理制度
- 學(xué)紅色文化管理制度
- 安全辦工作管理制度
- 安全風(fēng)險(xiǎn)源管理制度
- 寶格麗酒店管理制度
- 實(shí)驗(yàn)室崗位管理制度
- 客戶應(yīng)收款管理制度
- 客運(yùn)站衛(wèi)生管理制度
- 家具制造業(yè)管理制度
- 2025-2030中國(guó)鋰電池正極材料行業(yè)市場(chǎng)發(fā)展趨勢(shì)與前景展望戰(zhàn)略研究報(bào)告
- 銀行柜員考試:外匯管理考試題庫(kù)
- 2024版壓力容器設(shè)計(jì)審核機(jī)考題庫(kù)-多選3-1
- DB23T 3840-2024非煤礦山隱蔽致災(zāi)因素普查治理工作指南
- 保密法知識(shí)權(quán)威課件
- 解除餐廳合同協(xié)議
- 全球電力行業(yè)的技術(shù)創(chuàng)新與展望
- 2025年消防機(jī)器人市場(chǎng)前景分析
- 預(yù)防艾梅乙母嬰傳播知識(shí)
- 總監(jiān)述職報(bào)告
- 兒童意外傷害預(yù)防及家庭安全教育推廣研究報(bào)告
評(píng)論
0/150
提交評(píng)論