已知有下面的类说明: pubic class Test4 { private float f=0f; int m=12; static int n=1; public static void main(String args[]) { Test4 e=new Test4(); } } 在main()方法中,下面( )使用是正确的。
A.e.f
B.this.n
C.Test4.m
D.Test4.f
第1题:
A.t.f
B.this.n
C.Test.m
D.Test.n
第2题:
类Test定义如下,将下列______方法插入③行处是不合法的。 ( )①public class Test{②public float Method(float a,float b){}③④}
A.public float Method(float a,float b,float c){}
B.public float Method(float c,float d){}
C.public int Method(int a,int b){}
D.private float Method(int a,int b,int c){}
第3题:
已知有下列类的说明,则下列哪个语句是正确的?public class Test { private float f=1.0f; int m=12; static int n=1; public static void main(String arg[]) { Test t= new Test(); }}
A.t.f;
B.this. n
C.Test.m;
D.Test.f;
第4题:
下面代码的执行结果是( )。 public class test { public static void main (String args[]) { float m=5.0f; int n=4; System.out.println((++m)*(n--)); } }
A.20.0
B.20
C.24.0
D.24
第5题:
阅读下面程序 public class Test4 { public static void main(String[] args) { int 1=10,j=3; float m=213.5f,n=4.0f; System.out.println(i%j); System.out.println(m%n); } } 程序运行的结果是
A.1.0和1.5
B.1和1.5
C.1.0和2.5
D.1和2.5
第6题:
下列代码执行结果为 ( )public class Test{ public static void main(String args[]){ float p=0f; int q=3; System.out.println(++p)*(q--)); }}
A.16
B.24
C.16
D.24
第7题:
类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){ }
第8题:
已知有下列类的说明,则下列哪个语句是正确的? ( ) public class Test { private float f=1.0f; int m=2; static int n=1; public static void main(String arg[]) { Test t=new Test(); } }
A.t.f;
B.this,n;
C.Test.m;
D.Test.f;
第9题:
有下列程序: #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()
A.n=0
B.n=l
C.n=2
D.n=3
第10题:
类中包含了一个静态成员函数,则main函数中和P.f1(P);语句具有同样功能的语句为______。
include<iostream.h>
class M
{public:
M(int A){A=a;B+=a;}
static void f1(M m);
private:
int A;
static int B;};
void M::f1(M m)
{
cout<<“A=“<<m.A((end1;
cout<<“B=”<<m.B<<en
第11题:
public class MethodOver { public void setVar (int a, int b, float c) { } } Which two overload the setVar method?()
第12题:
public class MethodOver { private int x, y; private float z; public void setVar(int a, int b, float c){ x = a; y = b; z = c; } } Which two overload the setVar method?()
第13题:
给出下列代码,如何使成员变量m被方法fun( )直接访问?Class Test{private int m;public static void fun( ){} }
A.将private int m改为protected int m
B.将private int m改为public int m
C.将private int m改为static int m
D.将private int m改为int m
第14题:
给出下列代码,如何使成员变量m被方法fun( )直接访问? class Test{ private int m; public static void fun( ){ … } }
A.将private int m改为protected int m
B.将private int m改为public int m
C.将private int m改为static i
D.将private int m改为int m
第15题:
已知有下列类的说明,则下列( )语句是正确的。 publicClass Test{ private float f=1.0f; int m=12; static int n=1: public static void main(Stringarg[]){ Test t=new Test(): } }
A.t.f;
B.this.n;
C.Test.m;
D.Test.f;
第16题:
已知有下面的类说明: public class Test4 { private float f=1.0f; int m=12; static int n=1; public static void main(String args[]) { Test4 e=new Test4(); } } 在main()方法中,下面哪个的使用是正确的? ( )
A.e.f
B.this.n
C.Test4.m
D.Test4.f
第17题:
下列程序的执行结果是【 】。
include < iostream. h>
class Myclass
{
public:
void GetSum(int a)
static int Sum:
private:
int A;
};
int Myclass:: Sum =10; //必须在类外部对静态数据成员初始化
void Myelass: :GetSum(int a)
{
A=a;
Sum+=A;
}
void PrintSum(Myclass& A)
{
cout<<"Sum="<<A.Sum<<end1;
}
void main( )
{
Myclass M,N;
M. GetSum(3)
N. GetSum(7)
PrintSum(M);
}
第18题:
下列代码的执行结果是( )。 public class Test1 { public static void main(String args[]) float t = 0f; int q = 5; System.out.println((t++)*(--q)); }
A.40
B.40
C.36
D.36
第19题:
以下程序的执行结果是______。
include<iostream.h>
class CSample
{
private:
int n;
static int k:
public:
CSample (int i) {n=i;k++;};
voiddisp();
} ;
void CSample::disp()
{
cout <<"n="<<n<<",k="<<k<<endl
}
int CSample:
第20题:
类Test定义如下,将下列哪个方法插入③行处是不合法的( )?
① public class Test{
② public float Method(float a,float B) { }
③ ______
④ }
A.public float Method(float a,float b,float C) { }
B.public float Method(float c,float d){ }
C.public int Method(int a,int B) { }private float Method(int a,int b,int C) { }
D.private float Method(int a,int b,int C) { }
第21题:
已知有下列类的说明,则下列哪个语句是正确的? public class Test{ private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[ ]){ Test t = new Test( ); } }
A.t.f;
B.this.n;
C.Test.m;
D.Test.f;
第22题:
对于下面定义的类MyClass,请在函数f( )中添加对象成员把n的值修改为50。
class MyClass
{
public:
MyClass(int x){n=x;}
void SetNum(int n1){n=n1;}
private:
int n;
};
void f()
{
My Class*ptr=new MyClass(45);
【12】
}
第23题:
类Test1定义如下: 1.public class Test1{ 2. public float aMethod(float a,float b){ return 0;} 3. 4.} 将以下哪种方法插入行3是不合法的。()