类Test1定义如下: 1.public class Test1{ 2. public float aMethod(float a,float b){ return 0;} 3. 4.} 将以下哪种方法插入行3是不合法的。()
第1题:
下列代码的执行结果为( )。 public class Test1 { public static void main(String args[]){ hat a=3,b=10; System.out.println((a++)*(--b)); }
A.40
B.36
C.30
D.27
第2题:
下列关于Test类的定义中,正确的是______。
A) class Test implements Runnabte{
public void run(){}
public void someMethod(){}
B) class Test implements Rnuuable{
public void run();
}
C) class Test implements Rnuuable{
public void someMethod();
}
D) class Test implements Rnuuable{
public void someMethod();{}
}
A.
B.
C.
D.
第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){}
第4题:
有如下类定义: 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.t.x=10;
B.t.y=10;
C.t. setX(10);
D.int m=t.getX( );
第5题:
A.public class test { public int x = 0; public test(int x) { this.x = x; } }
B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }
C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }
D.public class
第6题:
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
A.n=0
B.n=1
C.n=2
D.n=3
第7题:
A.t.f
B.this.n
C.Test.m
D.Test.n
第8题:
有如下类定义:
class Test
{
public:
Test(){ a = 0; c = 0;} // ①
int f(int a)const{this->a = a;} // ②
static int g(){return a;} // ③
void h(int
B . {Test::b = b;}; // ④
private:
int a;
static int b;
const int c;
};
int Test::b = 0;
在标注号码的行中,能被正确编译的是
A . ①
B . ②
C . ③
D . ④
第9题:
有如下的类的模板定义:
template <class T>
class MyClass
{
private:
T number;
public:
MyClass(T k);
…
};
其中构造函数MyClass()用k的值初始化数据成员n。因此在模板类体外,构造函数
MyClass应定义为【 】。
第10题:
有如下类定义: class Test { public: Test(){a=0;c=0} //① int f(int a)const{this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b;}; //④ private: int a; static int b; const int C; }; int Test::b=0; 在标注号码的行中,能被正确编译的是( )。
A.①
B.②
C.③
D.④