2009年2月11日 星期三

第72題

Given:
1. package geometry;
2. public class Hypotenuse {
3. public InnerTriangle it = new InnerTriangle();
4. class InnerTriangle {
5. public int base;
6. public int height;
7. }
8. }
Which statement is true about the class of an object that can reference the variable base?
A. It can be any class.
B. No class has access to base.
C. The class must belong to the geometry package.
D. The class must be a subclass of the class Hypotenuse.
答案:C
參考:7-3 存取修飾詞的使用

-----------------------------------------------

要讀取變數 base,必須使用inner class Inner Triangle, 因 InnerTriangle是 default, 所以必須在一樣的package裡面.

沒有留言:

張貼留言