"SCJP 1.6版考題 106" 修訂間的差異
出自 陳富國維基館
(新頁面: Given classes defined in two different files: 1. package util; 2. public class BitUtils{ 3. public static void process(byte[] b){→more code here:} 4. } 1. package app; 2. ...) |
(無差異)
|
於 2013年3月30日 (六) 05:35 的最新修訂
Given classes defined in two different files: 1. package util; 2. public class BitUtils{ 3. public static void process(byte[] b){/* more code here */} 4. } 1. package app; 2. public class SomeApp{ 3. public static void main(String[] args){ 4. byte[] bytes = new byte[256]; 5. //insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils? A. process(bytes); B. BitUtils.process(bytes); C. util.BitUtils.process(bytes); D. SomeApp cannot use methods in BitUtils. E. import util.BitUtils.*; process(bytes);
解答
Ans: C
解說:
SomeApp在app套件下, BitUtils在util套件下, SomeApp要存取BitUtils要先套BitUtils的套件名稱util, process方法是BitUtils的類別方法,所以直接用util.BitUtils.process表示。
|