"SCJP 1.6版考題 057" 修訂間的差異
出自 陳富國維基館
(新頁面: 21. class Money{ 22. private String country = "Canada"; 23. public String getC(){return country;} 24. } 25. class Yen extends Money{ 26. public String getC(){return super...) |
(無差異)
|
於 2013年3月30日 (六) 07:11 的最新修訂
21. class Money{ 22. private String country = "Canada"; 23. public String getC(){return country;} 24. } 25. class Yen extends Money{ 26. public String getC(){return super.country;} 27. } 28. public class Euro extends Money{ 29. public String getC(){return super.getC();} 30. public static void main(String[] args){ 31. System.out.print(new Yen().getC() + " " + new Euro().getC()); 32. } 33. } What is the result? A. Canada B. null Canada C. Canada null D. Canada Canada E. Compilation fails due to an error on line 26. F. Compilation fails due to an error on line 29.
解答
Ans: E
解說: Money中的country存取屬性是private,在類別Yen中無法存取country屬性
|