Class B’s constructor is public.
Class B’s constructor has no arguments.
Class B’s constructor includes a call to this().
Class B’s constructor includes a call to super().
第1题:
有如下程序:#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"<<en+dl; } ~test(){cout<<"destructor"<<endl;}};int main(){ test A(3); rerun 0;}运行时输出的结果是
A.3
B.constructor destructor
C.copy constructor destructor
D.3 destructor
第2题:
下列程序时类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')
}
第3题:
What happens when you try to compile and run the following program?
class Mystery{String s;public static void main(String[] args){
Mystery m=new Mystery();m.go();}void Mystery(){s=”constructor”;}void go(){System.out.println(s);}
}()
A.this code will not compile
B.this code compliles but throws an exception at runtime
C.this code runs and “constructor” in the standard output
D.this code runs and writes “null” in the standard output
第4题:
Which two statements are true regarding the creation of a default constructor?()
第5题:
class A { A() { } } class B extends A { } Which two statements are true?()
第6题:
A.class中的constructor不可省略
B.constructor在一个对象被new时执行
C.一个class只能定义一个constructor
D.constructor必须与class同名,但方法不能与class同名
第7题:
有如下程序: #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
第8题:
下列说法正确的有()
A.class中的constructor不可省略
B.constructor必须与class同名,但方法不能与class同名
C.constructor在一个对象被new时执行
D.一个class只能定义一个constructor
第9题:
Which three statements are true?()
第10题:
In which two cases does the compiler supply a default constructor for class A?()