Question 27: To determine if you can invoke addContainerListener() for a component referenced using a variable named c, which expression(s) can you evaluate that will give you a true or false answer to this questions?
Select all valid answers.
a) c == Container
b) c.equals(Class.Container)
c) c instanceof Container
d) c instanceof Component
e) c implements Container
answer
--------------------------------------------------------------------------------Question 28: Write a statement for a constructor that invokes the no-args, default constructor in its superclass.
Fill in the blank
Answer---------------这个是填空题,
看不大懂,请大家帮帮忙,谢谢!

解决方案 »

  1.   

    Question 28:
    写一个构造函数,调用其父类的无参数构造函数Super();
      

  2.   

    第一个选择“c”
    c肯定是正确的,第二个:
    public MyClass(){
          super();
    }
      

  3.   

    Question 27: 好像是Swing方面的,Swing我基本没用过,不过在TIJ中看到,有点印象,查了一下书,说:SWING组件都有addXXXListener方法来实现监听,其参数应当就是XXX,也就是说addContainerListener()方法的参数应当是个Container对象。所以,既然能调用c的addContainerListener方法,那么c应当是一个Swing组件,所以选
    d) c instanceof Component望Swing达人指正
      

  4.   

    Question 27 key :
    c) c instanceof Container 
    d) c instanceof Component Question 28 key :
    super()
      

  5.   

    因为 Componet的Container的父类 
    所以用 instanceof 的时候得到的是 true例:
    class A{
    }class B extends A{
    }
    public class Test{ public static void main(String[] args) {
    B b = new B();
    if (b instanceof B) System.out.println("ok1");
    if (b instanceof A) System.out.println("ok2");
    }
    }
      

  6.   

    第一个问题答案d)不对吧?
    Component 可以addContainerListener()吗?
      

  7.   

    Container extends Component
    所以c和d都对
      

  8.   

    第一个d不对,只能选c 第二个: super()
      

  9.   

    Question 27: To determine if you can invoke addContainerListener() for a component 
    referenced using a variable named c, which expression(s) can you evaluate that will 
    give you a true or false answer to this questions?
    Select all valid answers.
    a) c == Container
    b) c.equals(Class.Container)
    c) c instanceof Container
    d) c instanceof Component
    e) c implements Container问题 27:有一个名子为C的组件(component),是否可以对这个组件调用addContainerListener()方法?下面的哪个(一个或者多个)表达式能够解决上面的问题,并且对这个问题给出“是”或者“否”的答案。
    选择所有的答案。
    a)c == Container
    b)c.equals(Class.Container)
    c)c instanceof Container
    d)c instanceof Component
    e)c implements Container其实如果一个组件(component)是Container的子类就可以调用addContainerListener()方法。所以关键是5个选项中,哪个能判断出来c是Container的子类。