class A { A() { } } class B extends A { } Which two statements are true?()
第1题:
下列程序时类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')
}
第2题:
Which two statements are true regarding the creation of a default constructor?()
第3题:
Which two statements are true regarding the creation of a default constructor?()
第4题:
Which two allow the class Thing to be instantiated using new Thing()?
第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?()
第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?()
第7题:
AnAdapter1 aa = new AnAdapter1 () {}
AnAdapter0 aa = new AnAdapter0 () {}
AnAdapter0 aa = new AnAdapter0 (5) {}
AnAdapter1 aa = new AnAdapter1 (5) {}
AnInterface ai = new Anlnterface (5)) {}
第8题:
The code will fail to compile.
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.
Class c has three constructors.
Objects of class b cannot be constructed.
At most one of the constructors of each class is called as a result of constructing an object of class c.
第9题:
AnAdapter1 aa=new AnAdapter1(){}
AnAdapter0 aa=new AnAdapter0(){}
AnAdapter0 aa=new AnAdapter0(5){}
AnAdapter1 aa=new AnAdapter1(5){}
AnInterface a1=new AnInterface(5){}
第10题:
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().
第11题:
public class Thing { }
public class Thing { public Thing() {} }
public class Thing { public Thing(void) {} }
public class Thing { public Thing(String s) {} }
public class Thing { public void Thing() {} public Thing(String s) {} }
第12题:
( 难度:中等)下列关于constructor说法正确的有()。
A.constructor在一个对象被new时执行
B.constructor必须与class同名,但方法不能与class同名
C.class中的constructor不可省略
D.一个class只能定义一个constructor
答案:A
第13题:
Which three statements are true?()
第14题:
In which two cases does the compiler supply a default constructor for class A?()
第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) {} }
第16题:
When compressing data with the DeflateStream class, how do you specify a stream into which to write compressed data?()
第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?()
第18题:
Create a new class that is derived from the Control class.Call the SetStyle method in the constructor.
Create a new class that is derived from theTextBox control class.Override the OnPaint method in the constructor.
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.
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.
第19题:
The default constructor initializes method variables.
The default constructor has the same access as its class.
The default constructor invoked the no-arg constructor of the superclass.
If a class lacks a no-arg constructor, the compiler always creates a default constructor.
The compiler creates a default constructor only when there are no other constructors for the class.
第20题:
第21题:
class A{}
class A { public A(){} }
class A { public A(int x){} }
class Z {} class A extends Z { void A(){} }
第22题:
The default constructor initializes method variables.
The compiler always creates a default constructor for every class.
The default constructor invokes the no-parameter constructor of the superclass.
The default constructor initializes the instance variables declared in the class.
When a class has only constructors with parameters, the compiler does not create a default constructor.
第23题:
The default constructor initializes method variables.
The default constructor invokes the no-parameter constructor of the superclass.
The default constructor initializes the instance variables declared in the class.
If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a default constructor.
The compiler creates a default constructor only when there are no other constructors for the class.