"SCJP 1.6版考題 031" 修訂間的差異
出自 陳富國維基館
(新頁面: 1. public class Base{ 2. public static final String FOO = "foo"; 3. public static void main(String[] args){ 4. Base b = new Base(); 5. Sub s = new Sub(); 6. Syste...) |
(無差異)
|
於 2013年3月30日 (六) 08:15 的最新修訂
1. public class Base{
2. public static final String FOO = "foo";
3. public static void main(String[] args){
4. Base b = new Base();
5. Sub s = new Sub();
6. System.out.print(Base.FOO);
7. System.out.print(Sub.FOO);
8. System.out.print(b.FOO);
9. System.out.print(s.FOO);
10. System.out.print(((Base)s).FOO);
11. }
12.}
13.class Sub extends Base{public static final String FOO = "bar";}
What is the result?
A. foofoofoofoofoo
B. foobarfoobarbar
C. foobarfoofoofoo
D. foobarfoobarfoo
E. barbarbarbarbar
F. foofoofoobarbar
G. foofoofoobarfoo
解答
Ans: D
解說: FOO皆是類別成員,存取時以參考的型態為主
| ||||||||||||||||||||