多选题AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.   W

题目
多选题
AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.   Which two construct an anonymous inner class? ()
A

AnAdapter1 aa=new AnAdapter1(){}

B

AnAdapter0 aa=new AnAdapter0(){}

C

AnAdapter0 aa=new AnAdapter0(5){}

D

AnAdapter1 aa=new AnAdapter1(5){}

E

AnInterface a1=new AnInterface(5){}


相似考题
更多“多选题AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.   W”相关问题
  • 第1题:

    以下程序的输出结果是_____。 include class object {private:int val; public:objec

    以下程序的输出结果是_____。

    include<iostream.h>

    class object

    { private:

    int val;

    public:

    object( ) ;

    object(int i) ;

    ~object( ) ;};

    object: :object( )

    { val=0;

    cout < < "Default constructor for object" < < endl;}

    object: :object(int i)

    { val=i;

    cout < < "Constructor for object" < < val < < endl;}

    object: :~object( )

    { cout < < "Destructor for object" < < val < < endl;}

    class container{ private:

    object one;

    object two;

    int data;

    public:

    container( ) ;

    container(int i,int j,int k) ;

    ~container( ) ;};

    container: :container( )

    { data=0;

    cout < < "Default constructor for container" < < endl;}

    container: :container(int i,int j,int k) :two(i) ,one(j)

    { data=k;

    cout < < "Constructor for container" < < endl;}

    container: :~container( )

    { cout < < "Destructor for container" < < endl;}

    void main( )

    { container anObj(5,6,10) ;}


    正确答案:Constructor for object6 Constructor for object5 Constructor for container Destructor for container Destructor for object5 Destructor for object6
    Constructor for object6 Constructor for object5 Constructor for container Destructor for container Destructor for object5 Destructor for object6 解析:C++语言中的构造函数和析构函数分别是在声明对象时和对象调用完毕后调用,本题中的调用就是这样成对出现的。

  • 第2题:

    C# provides, by default a parameterless constructor. If I write a constructor that takes a string as a parameter, but want to keep the parameterless constructor. How many constructors should I write?

    (C#提供默认构造函数(不带参数),如果我写了一个带有一个string类型参数的构造函数,但是又想保留不带参数的构造函数,那么我需要写多少个构造函数)


    正确答案:
     

  • 第3题:

    class A {  A() { }  }  class B extends A {  }  Which two statements are true?()

    • A、 Class B’s constructor is public.
    • B、 Class B’s constructor has no arguments.
    • C、 Class B’s constructor includes a call to this().
    • D、 Class B’s constructor includes a call to super().

    正确答案:B,D

  • 第4题:

    Which two statements are true regarding the creation of a default constructor?()   

    • A、 The default constructor initializes method variables.
    • B、 The default constructor invokes the no-parameter constructor of the superclass.
    • C、 The default constructor initializes the instance variables declared in the class.
    • D、 If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a default constructor.
    • E、 The compiler creates a default constructor only when there are no other constructors for the class.

    正确答案:C,E

  • 第5题:

    In which two cases does the compiler supply a default constructor for class A?()  

    • A、 class A{}
    • B、 class A { public A(){} }
    • C、 class A { public A(int x){} }
    • D、 class Z {} class A extends Z { void A(){} }

    正确答案:A,D

  • 第6题:

    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  

    • A、The code will fail to compile.
    • B、The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.
    • C、Class c has three constructors.
    • D、Objects of class b cannot be constructed.
    • E、At most one of the constructors of each class is called as a result of constructing an object of class c.

    正确答案:B,C

  • 第7题:

    Given the uncompleted code of a class:     class Person {  String name, department;     int age;  public Person(String n){  name = n; }  public Person(String n, int a){  name = n;  age = a;  }  public Person(String n, String d, int a) {  // doing the same as two arguments version of constructor     // including assignment name=n,age=a    department = d;     }     }  Which expression can be added at the "doing the same as..." part of the constructor?() 

    • A、 Person(n,a);
    • B、 this(Person(n,a));
    • C、 this(n,a);
    • D、 this(name,age);

    正确答案:C

  • 第8题:

    You are creating a Windows Forms application by using the .NET Framework 3.5. You plan to develop a new control for the application.The control will have the same properties as a TextBox control.You need to ensure that the control has a transparent background when it is painted on form.You want to achieve this goal by using the minimum amount of development effort.What should you do?()

    • A、Create a new class that is derived from the Control class.Call the SetStyle method in the constructor.
    • B、Create a new class that is derived from theTextBox control class.Override the OnPaint method in the constructor.
    • C、Create a new class that is derived from the Control class.Set the BackColor property of the control to Transparent.Call the SetStyle method in the constructor.
    • D、Create a new class that is derived from theTextBox control class.Set the BackColor property of the control to Transparent in the constructor.Call the SetStyle method in the constructor.

    正确答案:D

  • 第9题:

    多选题
    Which three statements are true?()
    A

    The default constructor initializes method variables.

    B

    The default constructor has the same access as its class.

    C

    The default constructor invoked the no-arg constructor of the superclass.

    D

    If a class lacks a no-arg constructor, the compiler always creates a default constructor.

    E

    The compiler creates a default constructor only when there are no other constructors for the class.


    正确答案: E,D
    解析: 暂无解析

  • 第10题:

    多选题
    AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.   Which two construct an anonymous inner class? ()
    A

    AnAdapter1 aa=new AnAdapter1(){}

    B

    AnAdapter0 aa=new AnAdapter0(){}

    C

    AnAdapter0 aa=new AnAdapter0(5){}

    D

    AnAdapter1 aa=new AnAdapter1(5){}

    E

    AnInterface a1=new AnInterface(5){}


    正确答案: B,D
    解析: 暂无解析

  • 第11题:

    多选题
    class A {  A() { }  }  class B extends A {  }  Which two statements are true?()
    A

    Class B’s constructor is public.

    B

    Class B’s constructor has no arguments.

    C

    Class B’s constructor includes a call to this().

    D

    Class B’s constructor includes a call to super().


    正确答案: D,B
    解析: 暂无解析

  • 第12题:

    多选题
    Which two statements are true regarding the creation of a default constructor?()
    A

    The default constructor initializes method variables.

    B

    The default constructor invokes the no-parameter constructor of the superclass.

    C

    The default constructor initializes the instance variables declared in the class.

    D

    If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a default constructor.

    E

    The compiler creates a default constructor only when there are no other constructors for the class.


    正确答案: E,B
    解析: 暂无解析

  • 第13题:

    Copy constructor.


    正确答案:
     

  • 第14题:

    有如下程序: #inClude<iostream> using namespaCe std; Class test{ private: int a; publiC: test( ){Cout<<”ConstruCtor”<<endl;} test(int A.{Cout<<a<<endl;} test(Const test&_test){ a=test.a: Cout<<”Copy ConstruCtor”<<endl: } test( ){Cout<<”destruCtor”<<endl;} }; int main( ){ test A(3); return 0; } 执行这个程序的输出结果是( )。

    A.3

    B.ConstruCtor destruCtor

    C.Copy ConstruCtor destruCtor

    D.3 destruCtor


    正确答案:D
    本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数.输出3,然后执行析构溺数,输出destructor。所以本题答案为D。

  • 第15题:

    Which three statements are true?()

    • A、 The default constructor initializes method variables.
    • B、 The default constructor has the same access as its class.
    • C、 The default constructor invoked the no-arg constructor of the superclass.
    • D、 If a class lacks a no-arg constructor, the compiler always creates a default constructor. 
    • E、 The compiler creates a default constructor only when there are no other constructors for the class.

    正确答案:B,C,E

  • 第16题:

    AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.   Which two construct an anonymous inner class()?

    • A、 AnAdapter1 aa = new AnAdapter1 () {}
    • B、 AnAdapter0 aa = new AnAdapter0 () {}
    • C、 AnAdapter0 aa = new AnAdapter0 (5) {}
    • D、 AnAdapter1 aa = new AnAdapter1 (5) {}
    • E、 AnInterface ai = new Anlnterface (5)) {}

    正确答案:B,D

  • 第17题:

    Which two statements are true regarding the creation of a default constructor?() 

    • A、 The default constructor initializes method variables.
    • B、 The compiler always creates a default constructor for every class.
    • C、 The default constructor invokes the no-parameter constructor of the superclass.
    • D、 The default constructor initializes the instance variables declared in the class.
    • E、 When a class has only constructors with parameters, the compiler does not create a default constructor.

    正确答案:D,E

  • 第18题:

    Which line contains a constructor in this class definition?()   public class Counter { // (1)   int current, step;   public Counter(int startValue, int stepValue) { // (2)   set(startValue);   setStepValue(stepValue);  }   public int get() { return current; } // (3)   public void set(int value) { current = value; } // (4)   public void setStepValue(int stepValue) { step = stepValue; } // (5)  }  

    • A、Code marked with (1) is a constructor
    • B、Code marked with (2) is a constructor
    • C、Code marked with (3) is a constructor
    • D、Code marked with (4) is a constructor
    • E、Code marked with (5) is a Constructor

    正确答案:B

  • 第19题:

    AnInterface is an interface.   AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.   AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.    Which two construct an anonymous inner class?()   

    • A、AnAdapter1 aa=new AnAdapter1(){}
    • B、AnAdapter0 aa=new AnAdapter0(){}
    • C、AnAdapter0 aa=new AnAdapter0(5){}
    • D、AnAdapter1 aa=new AnAdapter1(5){}
    • E、AnInterface a1=new AnInterface(5){}

    正确答案:B,D

  • 第20题:

    多选题
    AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. An Adapterl is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.   Which two construct an anonymous inner class()?
    A

    AnAdapter1 aa = new AnAdapter1 () {}

    B

    AnAdapter0 aa = new AnAdapter0 () {}

    C

    AnAdapter0 aa = new AnAdapter0 (5) {}

    D

    AnAdapter1 aa = new AnAdapter1 (5) {}

    E

    AnInterface ai = new Anlnterface (5)) {}


    正确答案: D,C
    解析: 暂无解析

  • 第21题:

    多选题
    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }
    A

    The code will fail to compile.

    B

    The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.

    C

    Class c has three constructors.

    D

    Objects of class b cannot be constructed.

    E

    At most one of the constructors of each class is called as a result of constructing an object of class c.


    正确答案: E,D
    解析: 暂无解析

  • 第22题:

    多选题
    In which two cases does the compiler supply a default constructor for class A?()
    A

    class A{}

    B

    class A { public A(){} }

    C

    class A { public A(int x){} }

    D

    class Z {} class A extends Z { void A(){} }


    正确答案: C,D
    解析: 暂无解析

  • 第23题:

    多选题
    Which two statements are true regarding the creation of a default constructor?()
    A

    The default constructor initializes method variables.

    B

    The compiler always creates a default constructor for every class.

    C

    The default constructor invokes the no-parameter constructor of the superclass.

    D

    The default constructor initializes the instance variables declared in the class.

    E

    When a class has only constructors with parameters, the compiler does not create a default constructor.


    正确答案: B,A
    解析: 暂无解析

  • 第24题:

    ( 难度:中等)下列关于constructor说法正确的有()。
    A.constructor在一个对象被new时执行
    B.constructor必须与class同名,但方法不能与class同名
    C.class中的constructor不可省略
    D.一个class只能定义一个constructor

    答案:A