<span id="plx27"><var id="plx27"></var></span>
<dfn id="plx27"><var id="plx27"></var></dfn>
  • <span id="plx27"><code id="plx27"><input id="plx27"></input></code></span>
    <menu id="plx27"></menu><menuitem id="plx27"><thead id="plx27"><input id="plx27"></input></thead></menuitem>
  • <label id="plx27"><code id="plx27"></code></label>
    <label id="plx27"><button id="plx27"></button></label>
  • 歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
    裝配圖網(wǎng)
    ImageVerifierCode 換一換
    首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

    《面向?qū)ο蟪绦蛟O(shè)計(jì)》試題.doc

    • 資源ID:9159246       資源大?。?span id="4pb5plb" class="font-tahoma">94KB        全文頁數(shù):8頁
    • 資源格式: DOC        下載積分:9.9積分
    快捷下載 游客一鍵下載
    會(huì)員登錄下載
    微信登錄下載
    三方登錄下載: 微信開放平臺(tái)登錄 支付寶登錄   QQ登錄   微博登錄  
    二維碼
    微信掃一掃登錄
    下載資源需要9.9積分
    郵箱/手機(jī):
    溫馨提示:
    用戶名和密碼都是您填寫的郵箱或者手機(jī)號(hào),方便查詢和重復(fù)下載(系統(tǒng)自動(dòng)生成)
    支付方式: 支付寶    微信支付   
    驗(yàn)證碼:   換一換

     
    賬號(hào):
    密碼:
    驗(yàn)證碼:   換一換
      忘記密碼?
        
    友情提示
    2、PDF文件下載后,可能會(huì)被瀏覽器默認(rèn)打開,此種情況可以點(diǎn)擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
    3、本站不支持迅雷下載,請(qǐng)使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
    4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
    5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請(qǐng)知曉。

    《面向?qū)ο蟪绦蛟O(shè)計(jì)》試題.doc

    裝訂線得分一、程序修改(20分)說明:描述程序中的語法錯(cuò)誤原因并修改,每小題4分,錯(cuò)誤原因和改正錯(cuò)誤各2分。1. isPrime方法用于檢查參數(shù)num是否是質(zhì)數(shù)。public boolean isPrime(int num) boolean result = false; for(int i=2; i<num; i+) if(num%i=0) break; if(i>=num) result = true; return result;2. 具體類Reader實(shí)現(xiàn)了Readable接口。interface Readable void read(); class Reader implements Readable void read() System.out.println("I Can read it."); 3. main方法調(diào)用重載的max方法求2個(gè)數(shù)的最大值。public class Error03 public static double max(int a, double b) return a > b ? a : b; public static double max(double a, int b) return a > b ? a : b; public static void main(String args) double c = max(10, 100); 4. 子類Child覆蓋了父類Parent中的output方法。class Parent public final void output() System.out.println("Parent"); class Child extends Parent public void output() System.out.println("Child"); 5. main方法調(diào)用sum方法求數(shù)組所有元素的和。public class Error05 public double sum(double array) double result = 0; for (double value : array) result += value; return result; public static void main(String args) double arr = 1.0, 2.0, 3.0, 4.0, 5.0; System.out.println(sum(arr); 得分二、程序填空(20分)說明:填充程序中的空白,使程序能夠正確運(yùn)行,每空2分。1. 以下程序功能為輸入多個(gè)班的考試成績(jī),并分別計(jì)算每個(gè)班的總成績(jī)。import java.util.Scanner;public class Score /inputScore方法用于輸入一個(gè)班的所有成績(jī),參數(shù)num是班級(jí)的學(xué)生人數(shù) public static double inputScore(int num) double array = new doublenum; Scanner scanner = new Scanner(System.in); for (int i = 0; i < (1) ; i+) arrayi = scanner.nextDouble(); return array; public static double sumScore(double array) double result = 0; for (int i = 0; i < array.length; i+) result += arrayi; return result; public static void main(String args) double scores; int numOfClass, numOfStudent; Scanner scanner = new Scanner(System.in); System.out.print("一共有幾個(gè)班?"); numOfClass = scanner.nextInt(); scores = (2) ; for (int i = 0; i < numOfClass; i+) System.out.println("第" + (i + 1) + "班有幾人?"); numOfStudent = scanner.nextInt(); scoresi = inputScore( (3) ); for (int i = 0; i < numOfClass; i+) System.out.print("第" + (i + 1) + "班的總分:"); System.out.println(sumScore( (4) ); 2. 以下程序定義了Circle和Cylinder兩個(gè)類。/類1,Circle.javapublic class Circle private double radius; /圓的半徑 public Circle() /無參構(gòu)造方法 (5) /調(diào)用有參構(gòu)造方法將radius初始化為0.0 public Circle(double radius) (6) /把參數(shù)radius賦給數(shù)據(jù)域radius public double getArea() return (7) ; /求圓的面積,使用Math.PI public double getRadius() return radius; public void setRadius(double r) radius = r; /類2,Cylinder.javapublic class Cylinder extends Circle private double height; /圓柱的高度 public Cylinder() /無參構(gòu)造方法 this.height = 0.0; public Cylinder(double radius, double height) (8) ; /調(diào)用父類構(gòu)造方法將radius初始化為參數(shù)radius this.height = height; Override public double getArea() double area1 = (9) ; /求圓柱表面積double area2 = (10) ; /求圓柱的底面積return area1 + area2; public double getHeight() return height; public void setHeight(double height) this.height = height; 得分三、閱讀程序(20分)說明:閱讀以下每段程序,寫出運(yùn)行的結(jié)果,每小題5分。1. 閱讀程序1class Data public int a = 10, b = 100; public class Read01 public static void main(String args) int a = 10, b = 100; int array = 10, 100; Data data = new Data(); System.out.println("a=" + a + ",b=" + b); System.out.println("array0=" + array0 + ",array1=" + array1); System.out.println("data.a=" + data.a + ",data.b=" + data.b); swap(a, b); swap(array); swap(data); System.out.println("a=" + a + ",b=" + b); System.out.println("array0=" + array0 + ",array1=" + array1); System.out.println("data.a=" + data.a + ",data.b=" + data.b); public static void swap(int a, int b) int t = a; a = b; b = t; public static void swap(int array) int t = array0; array0 = array1; array1 = t; public static void swap(Data data) int t = data.a; data.a = data.b; data.b = t; 2. 閱讀程序2public class Read02 public static void main(String args) A x = new B(); System.out.println("(1)x.i: "+x.i); System.out.println("(2)(B)x.i: "+(B)x).i); System.out.println("(3)x.j: "+x.j); System.out.println("(4)(B)x.j: "+(B)x).j); System.out.println("(5)x.m1(): "+x.m1(); System.out.println("(6)(B)x.m1(): "+(B)x).m1(); System.out.println("(7)x.m2(): "+x.m2(); System.out.println("(8)x.m3(): "+x.m3(); class A public int i=1; public static int j=11; public static String m1() return "類A的靜態(tài)方法m1." public String m2() return "類A的實(shí)例方法m2." public String m3() return "類A的實(shí)例方法m3."class B extends A public int i=2; public static int j=22; public static String m1() return "類B的靜態(tài)方法m1." public String m2() return "類B的實(shí)例方法m2."3. 閱讀程序3class Person public Person() System.out.println("Person()"); class Employee extends Person public Employee() this("調(diào)用Employee(s)"); System.out.println("Employee()"); public Employee(String s) System.out.println(s); class Faculty extends Employee public Faculty() System.out.println("Faculty()"); class Test public static void main(String args) new Faculty(); 4. 閱讀程序4, 分別寫出?處的值是30和50的輸出結(jié)果。public class Read04 public static void main(String args) int value = ?; try if(value<40) throw new Exception("value is too small"); System.out.println("value="+value); catch (Exception e) System.out.println(e.getMessage(); finally System.out.println("process finished"); System.out.println("program continued"); 四、程序設(shè)計(jì)(40分)1. 設(shè)計(jì)并編寫一個(gè)名為MyPoint的類表示平面上一個(gè)具有x坐標(biāo)和y坐標(biāo)的點(diǎn),完成以下要求:(15分)l 將該類放置于包prog01中;l 兩個(gè)double類型數(shù)據(jù)域x和y表示坐標(biāo),并進(jìn)行封裝;l 無參構(gòu)造方法創(chuàng)建點(diǎn)(0.0, 0.0); 有參構(gòu)造方法按指定坐標(biāo)創(chuàng)建一個(gè)點(diǎn);l 方法distance返回當(dāng)前點(diǎn)對(duì)象到參數(shù)點(diǎn)對(duì)象之間的距離;l 編寫測(cè)試類TestMyPoint,其main方法中創(chuàng)建兩個(gè)點(diǎn)(0.0, 0.0)和(10.0, 35.5),輸出這兩個(gè)點(diǎn)之間的距離。2根據(jù)材料完成程序代碼(15分)。要求利用多態(tài)性計(jì)算若干不同類型幾何圖形的面積之和,類與接口的關(guān)系見下面的類圖。類CricleV1,類RectangleV1和測(cè)試類Tester的源碼已經(jīng)給出。CircleV1.javapublic class CircleV1 private double radius; public CircleV1() this(1.0); public CircleV1(double radius) this.radius = radius; public double getRadius() return radius; public void setRadius(double radius) this.radius = radius; RectangleV1.javapublic class RectangleV1 private double width; private double height; public RectangleV1() this(1.0, 1.0); public RectangleV1(double width, double height) this.width = width; this.height = height; public double getWidth() return width; public void setWidth(double width) this.width = width; public double getHeight() return height; public void setHeight(double height) this.height = height; Tester.javapublic class Tester public static void main(String args) Object shapes = new CircleV2(10), / new RectangleV2(10, 2), / new CircleV2(), / new RectangleV2() / ; System.out.println(sumArea(shapes); public static double sumArea(Object shapes) double result = 0; for (int i = 0; i < shapes.length; i+) if (shapesi instanceof CalcArea) / result += (CalcArea) shapesi).getArea(); / return result; 請(qǐng)根據(jù)以上給定的材料,完成以下代碼,使的Tester類中的main方法能夠順利運(yùn)行。注意Tester類中行尾有“/”標(biāo)注的行使用了你需要完成的接口和類。(1) 編寫完成接口CalcArea.java。(5分)(2) 編寫完成類CircleV2.java。(5分)(3) 編寫完成類RectangleV2.java。(5分)3. 根據(jù)材料完成程序代碼(15分)。import java.util.Date;public class Account private int id; /賬號(hào) private double balance; /賬戶余額 private Date createDate;/開戶日期 public Account(int id, double balance) this.id = id; this.balance = balance; this.createDate = new Date(); /取款方法 public void getMoney(double amt) /以下是3個(gè)訪問器方法 public int getId() return id; public double getBalance() return balance; public Date getCreateDate() return createDate; 根據(jù)以上給出的銀行賬戶類Account的定義,按要求完成以下代碼。說明:答卷上只填寫修改部分的代碼即可,原有代碼的其他部分不需要重寫。(1) 修改Account類的定義,使得Account類可以進(jìn)行序列化。(3分)(2) 修改并完成getMoney方法,要求:如果余額足夠,則減去參數(shù)amt給出的金額;否則getMoney方法拋出一個(gè)Exception異常對(duì)象,異常信息為“余額不足.”。(3分)(3) 修改Account類的定義,使得Account類可以進(jìn)行“深克隆”,說明:Date類可以進(jìn)行克隆。(4分)第 7 頁 共 8 頁

    注意事項(xiàng)

    本文(《面向?qū)ο蟪绦蛟O(shè)計(jì)》試題.doc)為本站會(huì)員(wux****ua)主動(dòng)上傳,裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng)(點(diǎn)擊聯(lián)系客服),我們立即給予刪除!

    溫馨提示:如果因?yàn)榫W(wǎng)速或其他原因下載失敗請(qǐng)重新下載,重復(fù)下載不扣分。




    關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

    copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

    備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


    本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!

    欧美久久久一区二区三区,国产精品亚洲一区二区无码,亚洲国产精品综合久久20声音,亚洲国产精品无码久久久蜜芽
    <span id="plx27"><var id="plx27"></var></span>
    <dfn id="plx27"><var id="plx27"></var></dfn>
  • <span id="plx27"><code id="plx27"><input id="plx27"></input></code></span>
    <menu id="plx27"></menu><menuitem id="plx27"><thead id="plx27"><input id="plx27"></input></thead></menuitem>
  • <label id="plx27"><code id="plx27"></code></label>
    <label id="plx27"><button id="plx27"></button></label>