2009年2月9日 星期一

第67題

10. abstract public class Employee {
11. protected abstract double getSalesAmount();
12. public double getCommision() {
13. return getSalesAmount() * 0.15;
14. }
15. }
16. class Sales extends Employee {
17. //insert method here
18. }
Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)

A. double getSalesAmount() { return 1230.45; }
B. public double getSalesAmount() { return 1230.45; }
C. private double getSalesAmount() { return 1230.45; }
D. protected double getSalesAmount() { return 1230.45; }
答案:BD
參考:6-5 繼承、7-5 抽象類別
---------------------------------------------------------------
實做的意思是要改寫一種...
A. double getSalesAmount() { return 1230.45; } //子類別存取修飾詞要大於父類別
C. private double getSalesAmount() { return 1230.45; } //子類別存取修飾詞要大於父類別

沒有留言:

張貼留言