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.
有点疑问啊,不是所有的class都可以访问吗?

解决方案 »

  1.   

    加一道吧,嘿嘿
    A company that makes Computer Assisted Design (CAD) software has, within its application, some utility
    classes that are used to perform 3D rendering tasks. The company's chief scientist has just improved the
    performance of one of the utility classes' key rendering algorithms, and has assigned a programmer to replace
    the old algorithm with the new algorithm. When the programmer begins researching the utility classes, she is
    happy to discover that the algorithm to be replaced exists in only one class. The programmer reviews that
    class's API, and replaces the old algorithm with the new algorithm, being careful that her changes adhere
    strictly to the class's API. Once testing has begun, the programmer discovers that other classes that use the
    class she changed are no longer working properly.
    What design flaw is most likely the cause of these new bugs?
    A. Inheritance
    B. Tight coupling
    C. Low cohesion
    D. High cohesion
    E. Loose coupling
    F. Object immutability
      

  2.   

    1.  InnerClass 在另外一个类里面,但它没有给访问修饰符,那就是包内的。只有包内才可以访问到 InnerClass,当然 base 最多就是包内的。2. 像是 A,一个方法覆盖和不覆盖可能变化了。或者有某个 static 方法覆盖了父类中的同样的 static 方法。
      

  3.   

    但是有个it可以用啊,it.base不可以?答案是C,B
      

  4.   

    但是有个it可以用啊,it.base不可以?答案是C,B