SCJP 1.6版考題 101
出自 陳富國維基館
Given: 10. package com.sun.scjp; 11. public class Geodetics { 12. public static final double DIAMETER = 12756.32; //kilometers 13. } Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.) A. import com.sun.scjp.Geodetics; public class TerraCarta{ public double halfway() {return Geodetics.DIAMETER/2.0;} B. import static com.sun.scjp.Geodetics; public class TerraCarta{ public double halfway(){return DIAMETER/2.0;}} C. import static com.sun.scjp.Geodetics.*; public class TerraCarta{ public double halfway(){return DIAMETER/2.0;}} D. package com.sun.scjp; public class TerraCarta{ public double halfway(){return DIAMETER/2.0;}}
解答
Ans: A C
解說:
DIAMETER是類別成員,使用時應該是用:類別名.類別成員名字,如A import static可以簡化使用類別成員時的”類別名.”,可以直接叫用類別成員,如C
|