作者:
aster30 (紫苑)
2014-07-23 11:42:27Given:
1. public class Blip{
2. protected int blipvert(int x){return 0;}
3. }
4. class Vert extends Blip{
5. //insert code here
6. }
Which five methods, inserted independently at line 5, will compile? (Choose
five.)
A. public int blipvert(int x){return 0;}
B. private int blipvert(int x){return 0;}
C. private int blipvert(long x){return 0;}
D. protected long blipvert(int x){return 0;}
E. protected int blipvert(long x){return 0;}
F. protected long blipvert(long x){return 0;}
G. protected long blipvert(int x, int y){return 0;}
答案B跟D錯 ACEFG對
B是因為繼承的方法權限只能更開放,故不能用private
但明明C也是private阿,為什麼C對?
D是因為overriding回傳型態要跟父類別相同
但明明F/G也改了回傳型別,為什麼對?
作者: pzyc79 2014-07-23 12:46:00
你標題不就寫了override or overload ,就overload啊...