全国信息技术应用考试

类Test1定义如下:1.publicclassTest1{2.publicfloataMethod(floata,floatb){}3.4.}将以下()方法插入行3是不合法的。A、public float aMethod(floata,floatb,floatc){}B、public float aMethod(floatc,floatd){}C、public int aMethod(inta,intb){}D、private float aMethod(inta,intb,intc){}

题目

类Test1定义如下:1.publicclassTest1{2.publicfloataMethod(floata,floatb){}3.4.}将以下()方法插入行3是不合法的。

  • A、public float aMethod(floata,floatb,floatc){}
  • B、public float aMethod(floatc,floatd){}
  • C、public int aMethod(inta,intb){}
  • D、private float aMethod(inta,intb,intc){}
如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

在Java中,类Animal中的方法printA()定义如下:publicvoidprintA(){inta=10;intresult=10%3;System.out.println(result);}在类Dog中方法printA()定义如下:publicvoidprintA(){inta=10;System.out.println(a/3);}Dog类的定义如下:classDogextendsAnimal{…}.Animalanimal=newDog();animal.printA();以上语句输出为()。

A.0

B.1

C.2

D.3

E.3.3333


参考答案:D

第2题:

若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class

若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。

A.k=i*j

B.int k;

C.return i;

D.void make();


正确答案:A
解析:因为派生类不能是基类的私有成员i和j(默认情况下,成员的属性为私有),所以表达式k=i*j是非法的。其余的访问权限都是许可的。

第3题:

Test2定义如下: 1.publicclassTest1 2.{publicfloataMethod(floata,floatb)throws 3.IOException{} 4.} 5.publicclassTest2extendsTest1{ 6. 7.} 将以下哪种方法插入行6是不合法的。()

A.floataMethod(floata,floatb){}

B.publicintaMethod(inta,intb)throwsException{}

C.publicfloataMethod(floatp,floatq){}

D.publicintaMethod(inta,intb)throwsIOException{}


参考答案:A

第4题:

有如下的类模板定义: templateclassMyClass{TYPE n; public:MyClass(TYPE k);… };

有如下的类模板定义:

template<typenameTYPE>

classMyClass{

TYPE n;

public:

MyClass(TYPE k);

};

其中构造函数MyClass用的值初始化数据成员n。因此在模板类体外,构造函数MyClass应定义______。


正确答案:templatetypename TYPE> TyClassTYPE>::MyClass(TYPE k):n(k){}
templatetypename TYPE> TyClassTYPE>::MyClass(TYPE k):n(k){}

第5题:

若类A和类B的定义如下:includeclass A{int i*j;public:int geti(){return i;}};class

若类A和类B的定义如下: #include<malloc.h> class A { int i*j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j; } ); 则上述定义中非法的表达式是( )。

A.k=i*j;

B.int k;

C.return i;

D.void make();


正确答案:A
解析:因为派生类不能访问基类的私有成员i和j(默认情况下,成员的属性为私有),所以表达式k=i*j是非法的。其余的访问权限都是许可的。

第6题:

SQL的数据类型可分为如下三类:预定义数据类型、构造数据类型和______定义数据类型。


正确答案:用户
用户

第7题:

若在某一个类定义中定义有如下的方法:abstractvoidperformDial();该方法属于()。

A、接口方法

B、最终方法

C、抽象方法

D、空方法


参考答案:C

第8题:

14类Test1定义如下: 1.publicclassTest1{ 2.publicfloataMethod(floata,floatb){} 3. 4.} 将以下哪种方法插入行3是不合法的。()

A.public floata Method(floata,floatb,floatc){}

B.public floata Method(floatc,floatd){}

C.public inta Method(inta,intb){}

D.private floata Method(inta,intb,intc){}


参考答案:B

第9题:

有如下的类的模板定义: template class MyClass { private:T number; public:MyClass(

有如下的类的模板定义:

template <class T>

class MyClass

{

private:

T number;

public:

MyClass(T k);

};

其中构造函数MyClass()用k的值初始化数据成员n。因此在模板类体外,构造函数

MyClass应定义为【 】。


正确答案:templateclassT>/MyClassT>::MyClass(T k):number(k){}
templateclassT>/MyClassT>::MyClass(T k):number(k){} 解析:类模板的成员函数的类体外的定义以“templateclass T>”开头。

第10题:

类testl定义如下: public class test1 { public float amethod(float a,float b){ } }

A.public foat amethod(float a,float b,foat c){ }

B.public float amethod(float c,float d){ }

C.public int amethod(int a,int b){ }

D.private float amethod(int a,int b,int c){ }


正确答案:B

更多相关问题