(1)Give an example of when inheritance is better and when composition is better. 
(2)Exemplify difference between
composition and aggregation. 
(3)Differentiate Composition, Delegation and Consultation using an example.
(4)How can you type-check delegations ? (language specific answer with an example will suffice).
今天到一家外企面试,给了这几个题,大家有会的吗?

解决方案 »

  1.   

    直接说感觉说部清楚,推荐参考一下java与模式。
      

  2.   

    这题目挺简单,想知道可以到我的群里找我
    JAVA技术联盟2号群,我是秋风
      

  3.   

    (1)Give an example of when inheritance is better and when composition is better. 
    给出一个例子说明什么时候继承好,什么时候组成好,很简单,就是is-a和has-a的关系。
    (2)Exemplify difference between 
    composition and aggregation. 
    举例说明组成关系和聚集关系的区别,学过UML的话这个也很简单了,组成关系中组件不能单独存在。
    (3)Differentiate Composition, Delegation and Consultation using an example. 
    用一个例子区别组件,代理和商量。不会
    (4)How can you type-check delegations ? (language specific answer with an example will suffice). 
    在使用代理的时候你如何进行类型检查。还是不会。
      

  4.   

    不懂不要乱翻译,delegations 是委派,经常是一种抽象到其具体子类的委派调用关系,proxy才是代理的翻译
    JAVA社区联盟2号群群号了69726300,我是秋风