SCJP題庫第067題

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; }
 
Ans: B D
 
解說:
Overridding規則
A/C錯是因為其存取屬性的開放性皆小於protected!

Comments

Popular posts from this blog

Android+Google Map API v3 Geocoding(地址轉經緯度度