更多"如下代码定义了一个类Test: class Test pr"的相关试题:
[单项选择]如下代码定义了一个类Test: class Test { private int y; Test (int x) { y:x; } }现在为Test 类生成一个对象,正确的语句是( )。
A. Test t = new Test( );
B. Test t=new Test(10, 20);
C. Test t;
D. Test t=new Test(10);
[单项选择]有如下类定义:
class Test
private int x;
public int y;
public void setX (int m) x=m;
public int getX( ) return x;
现用Test t=new Text( );生成一个对象t,则如下语句中,错误的是( )。
A. x=10;
B. y=10;
C. setX(10);
D. int m=t.getX( );
[单项选择]类A定义如下: class A { private int x=10; int getx( ) { return x;} } class B extends A { private int x=15; //需要覆盖getx( )方法 } 在下述方法中可以在类B中覆盖getx( )方法的是 ( )
A. int getx(){…}
B. int getx(float {…}
C. float getx(){…}
D. double getx(float {…}
[单项选择]有如下类定义: class Point{ private: static int how_many; }; ______how_many=0; 要初始化Point类的静态成员how_many,在下画线处应填入的内容是
A. int
B. static int
C. int Point::
D. static int Point::
[单项选择]有如下类定义: class Point{ private: static int how_many; }; ______how_many=0; 要初始化Point类的静态成员how_many,下划线处应填入的内容是
A. int
B. static int
C. int Point: :
D. static int Point
[单项选择]设有基类定义:
class Cbase
private:int a;
protected:int b;
public:int c;
;
派生类采用何种继承方式可以使成员变量b成为自己的私有成员
A. 私有继承
B. 保护继承
C. 公有继承
D. 私有、保护、公有均可
[单项选择]设有基类定义:class Cbase{ private:int a;protected. int b;public:int c;};派生类采用何种继承方式可以使成员变量b成为自己的私有成员( )。
A. 私有继承
B. 保护继承
C. 公有继承
D. 私有、保护、公有均可
[单项选择]有以下类定义 class MyClass { private: int id; char gender; char*phone; public: MyClass( ):id(0),gender('#'),phone(NULL){} MyClass(int no,char ge='#',char*ph=NULL) {id=no;gender=ge;phone=ph;} }; 下列类对象定义语句中错误的是
[单项选择]有如下类声明: class TestClass int i; private:int j; protected:int k; public:int m,n; 其中,私有成员的数量为( )。
A. 0
B. 1
C. 2
D. 3
[单项选择]设有基类定义: class Cbase { private: int a; protected: int b; public: int c; }; 派生类采用何种继承方式可以使成员变量b成为自己的私有成员
A. 私有继承
B. 保护继承
C. 公有继承
D. 私有、保护、公有均可
[单项选择]设有基类定义:
class Cbase
{ private:int a;
protected:int b;
public:int c;
};
派生类采用何种继承方式可以使成员变量b成为自己的私有成员
A. 私有继承
B. 保护继承
C. 公有继承
D. 私有、保护、公有均可
[单项选择]已知程序中已经定义了函数test,其原型是int test(int, int, int);,则下列重载形式中正确的是
A. char test(int,int,int);
B. double test(int,int,double);
C. int test(int,int,int=0);
D. float test(int,int,float=3.5F);
[单项选择]已知程序中已经定义了函数test,其原型是int test (int,int,int);,则下列重载形式中正确的是( )。
A. char test(int, int, in;
B. double test (int,int,doubl;
C. int test(int ,int, int=0);
D. float test(int,int,float=3.5;
[单项选择]已知程序中已经定义了函数test,其原型是int test(int,int,int);,则下列重载形式中正确的是______ 。
A. char test (int,int,int);
B. double test(int,int,double);
C. int test (int,int,int=0);
D. float test(int,int,float=3.5F);