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 sup

题目

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().

相似考题
更多“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 supe”相关问题
  • 第1题:

    下列程序时类D代码段出现编译错误,原因是【 】。 include class A { public:A(char c)

    下列程序时类D代码段出现编译错误,原因是【 】。

    include<iostream. h>

    class A

    {

    public:

    A(char c){cout<<"A's constructor."<<c<<endl;}

    ~A(){cout<<"A's destructor."<<endl;}

    };

    class B: virtual public A

    {

    public:

    B(char cb,char cd):A(cb) {cout<<"B's constructor."<<cd<<endl;}

    ~B(){cout<<"B's destructor."<<endl;}

    private:

    char b;

    };

    class C:virtual public A

    {

    public:

    C(char cc, char cd):A(cc)

    {cout<<"C's constructor. "<<cd<<endl;}

    ~C(){cout<<"C's destructor."<<endl;}

    };

    class D:public B,public C

    {

    public:

    D(char cd,char ce,char cf, char cg, char ch,char ci)

    :C(cf,cg),B(cd,ce),A(cd),aa(ch)

    {cout<<"D's constructor."<<ci<<endl;}

    ~D() {cout<<"D's destructor."<<endl;}

    private:

    A aa;

    };

    void main()

    {

    D ohj('a','b','c','d','e','f')

    }


    正确答案:类的继承出现二义性
    类的继承出现二义性 解析:本题就是通过实例来表现多继承时出现的二义性问题。多重继承比较复杂,尽管C++中提供了虚基类来解决这个问题,但在实际开发中由于过于复杂而往往尽量避免使用。

  • 第2题:

    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

  • 第3题:

    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

  • 第4题:

    Which two allow the class Thing to be instantiated using new Thing()?

    • A、 public class Thing { }
    • B、 public class Thing { public Thing() {} }
    • C、 public class Thing { public Thing(void) {} }
    • D、 public class Thing { public Thing(String s) {} }
    • E、 public class Thing { public void Thing() {} public Thing(String s) {} }

    正确答案:A,B

  • 第5题:

    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

  • 第6题:

    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

  • 第7题:

    多选题
    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
    解析: 暂无解析

  • 第8题:

    多选题
    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
    解析: 暂无解析

  • 第9题:

    多选题
    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
    解析: 暂无解析

  • 第10题:

    多选题
    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
    解析: 暂无解析

  • 第11题:

    多选题
    Which two allow the class Thing to be instantiated using new Thing()?
    A

    public class Thing { }

    B

    public class Thing { public Thing() {} }

    C

    public class Thing { public Thing(void) {} }

    D

    public class Thing { public Thing(String s) {} }

    E

    public class Thing { public void Thing() {} public Thing(String s) {} }


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

  • 第12题:

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

    答案:A

  • 第13题:

    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

  • 第14题:

    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

  • 第15题:

    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

  • 第16题:

    When compressing data with the DeflateStream class, how do you specify a stream into which to write compressed data?()

    • A、 Set the BaseStream property with the destination stream, and set the CompressionMode property to Compression.
    • B、 Specify the stream to write into the DeflateStream object is created (for example, in the constructor).
    • C、 Use the Write method of the DeflateStream class.
    • D、 Register for the BaseSream event of the DeflateStream class.

    正确答案:B

  • 第17题:

    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

  • 第18题:

    单选题
    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.


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

  • 第19题:

    多选题
    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
    解析: 暂无解析

  • 第20题:

    问答题
    使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。  1.在类TestClass中定义name为字符串类型,age为整型,请在注释∥********1********之后添加语句。  2.设置类TestClass0的基类为TestClass类的定义,请在注释∥********2********后添加语句。  3.在类TestClass的派生类TestClass0的公有成员中定义析构函数TestClass0,请在∥********3********后添加。  4.设置类TestClass1的基类为TestClass类的定义,请在∥********4********后实现。  本程序输出如下结果:  TestClass class constructor  TestClass0 class constructor  TestClass on class constructor  TestClass1 class constructor  TestClass1 class constructor  TestClass class constructor  TestClass0 class constructor  TestClass class constructor  注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。

    正确答案: 1.添加语句:char* name;int age;
    2.添力语句:class TestClass0:public TestClass
    3.添加语句:~TestClass0()
    4.添加语句:class TestClass1:public TestClass
    解析:1.题目1要求“TestClass中定义name为字符串类型,age为整型”。根据题目要求,在程序TestClass类中定义变量name和age,即“char* name;int age;”。
    2.题目2要求“设置类TestClass0的基类为TestClass类的定义”。在C++中,从已有的类产生一个新的子类,称为类的派生。声明派生类的一般形式为:class派生类名:[继承方式] 基类名。根据声明派生类的一般形式,这里补全“classTestClass0:public TestClass”。
    3.题目3要求“在类TestClass的派生类TestClass0的公有成员中定义析构函数TestClass0”。析构函数的名字是类名的前面加一个“~”符号,声明析构函数为“~TestClass0()”。
    4.题目4要求“设置类TestClass1的基类为TestClass1类的定义”,在第4个标识下补充“class TestClass1:public TestClass”。
    解析: 暂无解析

  • 第21题:

    多选题
    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
    解析: 暂无解析

  • 第22题:

    多选题
    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
    解析: 暂无解析

  • 第23题:

    多选题
    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
    解析: 暂无解析