SCJP 1.6版考題 054

出自 陳富國維基館
前往: 導覽搜尋
1. package test;
2.
3. class Target{
4.   public String name = "hello";
5. }
 

What can directly access and change the value of the variable name? 

  A. any class
  B. only the Target class
  C. any class in the test package
  D. any class that extends Target

解答


Ans: C

解說: Target類別為預設存取屬性(package),要存取name必先存取Target類別,要存取Target類別的類別必須為同屬test套件下的類別。