Inheritance

Java 程式

簡介

運算式

分枝

迴圈

陣列

函數

遞迴

錯誤處理

物件導向

封裝

繼承

多型

技巧

函式庫

字串

數學

正規表達式

容器

檔案

網路

資料庫

視窗

Thread

Listener

錯誤陷阱

相關檔案

相關資源

教學錄影

Eclipse

考題解答

訊息

相關網站

參考文獻

最新修改

簡體版

English

習題:物件導向練習

  1. 定義一個人(Person)的類別,具有姓名(name),電話(tel),郵件(email)等三個欄位.
  2. 定義一個學生(Student)的類別,學生類別繼承人的類別,並具有 學校、科系與學號.
  3. 寫一個主程式,將 Person("路人甲"), Student("學生乙"), Person("路人丙"), Student("學生丁")
     存入 persons 陣列中,並將該陣列印出來.

參考 :

  class Person {
    ...
    String toString() {
       ...
    }
  }

  class Student {
    ...
    String toString() {
      ...
    }
  }

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License