close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決 
50% off Print Subscription of USA Today

Get the news delivered to your doorstep. Lock in the savings and receive USA Today for just $0.75 a day.
From our sponsors
java 抽象類別問題
Dec 28th 2013, 06:53

正確答案為 b.

a.
抽象類別並未強制必須擁有抽象方法

編譯時這裡不會造成 error

抽象類別的非抽象方法,猶如替這個方法程序寫個默認版本

若子類別有 override 則參考子類別實作

反之則使用抽象類別本身的方法程序內容

b.
抽象類別無法用來建立新物件 (new Base)

其必須透過被繼承,使用子類別建立新物件才有實例

本題內改為 new Sub() 即可通過編譯

c.
並未硬性規定繼承者必須箝置 abstract, 故無錯誤

要求子類別也為抽象類別時才需箝置 abstract

d.
並未規定所有方法程序須箝制 final, 故無錯誤

final 效果為阻止方法程序的 override

也就是子類別禁止擁有相同名稱且同參數的方法程序

e.
編譯錯誤故不印出任何值

希望以上回答對您有幫助!

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 yisoajkls 的頭像
    yisoajkls

    2016徵求年菜推薦網路訂購最紅的商家.年菜訂購?台北年菜外送餐廳推薦(年菜)?年菜.今年不想做年菜推薦,網路宅配哪一家好?

    yisoajkls 發表在 痞客邦 留言(0) 人氣()