若有类Z说明class Z{staticint a;public:static void fStatic(Z&);};int Z::a=0;Z objZ;,则函数fStatic中访问数据a错误的是()。
第1题:
执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }
A.1
B.2
C.3
D.4
第2题:
以下程序输出结果是 ______。 #include<iostream.h> void fun(int x,int y,int z){z=x+y;} void main() { int a=10; fun (2,2,a); cout<<a; }
A.0
B.4
C.10
D.无定值
第3题:
若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m=c; } void display() { cout〈〈getx()〈〈","〈〈z〈〈","〈〈m〈〈end1; } }; int main ( ) { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是( )。
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
第4题:
若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
第5题:
第6题:
In which two cases does the compiler supply a default constructor for class A?()
第7题:
现有: class Test4 { public static void main (String [] args) { boolean X=true; boolean y=false; short Z=42; if((z++==42) && (y=true))z++; if((x=false) || (++z==45)) z++; System. out.println(¨z=”+z); } } 结果为:()
第8题:
现有: class Foo { public static void main (String [] args) { int x=O; int y=4; for (int z=0; z<3; Z++; X++) { if(x>1&++y<10) y++; } System. out .println (y); } } 结果是什么?()
第9题:
abstract class A { abstract void al(); void a2() { } } class B extends A { void a1() { } void a2() { } } class C extends B { void c1() { } } and: A x = new B(); C y = new C(); A z = new C(); Which four are valid examples of polymorphic method calls?()
第10题:
class Test4 { public static void main(String [] args) { boolean x = true; boolean y = false; short z = 42; if((z++ = = 42) && (y = true)) z++; if((x = false) || (++z = = 45)) z++; System.out.println("z = " + z); } } 结果为:()
第11题:
void Z::fStatic(){obj Z.a=1;}
void Z::fStatic(){a=1;}
void Z::fStatic(){this->a=0;}
void Z::fStatic(){Z::a=0;}
第12题:
void setVar (int a, int b, float c){ x = a; y = b; z = c; }
public void setVar(int a, float c, int b) { setVar(a, b, c); }
public void setVar(int a, float c, int b) { this(a, b, c); }
public void setVar(int a, float b){ x = a; z = b; }
public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
第13题:
若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是( )
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
第14题:
若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protected A { public: void setvalue(int a, int b, int c) { setx (a); y=b; z=c; } void display() { cout<<getx ( ) <<", "<<y<<", "<<z<<", "<<end1; } }; int main () { B obj; obj.setvalue(5, 6, 7); obj.display ( ); return 0; } 程序运行后的输出结果是( )。
A.产生语法错误
B.7,6,5
C.5,6,7
D.7,5,6
第15题:
以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第16题:
A. x=0,y=2,z=1
B. x=1,y=2,z=1
C. x=0,y=1,z=1
D. x=0,y=2,z=2
第17题:
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A }
第18题:
现有: class Test2 f public static void main (String [] args) { boolean X= true; boolean y=false; short Z=20; if((x==true) && (y=true)) z++; if((y==true) || (++z==22)) z++; System. out .println( "z="+z); } 结果是什么?()
第19题:
class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 & ++y 〈 10) y++; } System.out.println(y); } } 结果是什么?()
第20题:
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?()
第21题:
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()
第22题:
public int cal(int x,int y,float z){return 0;}
public int cal(int x,int y,int z){return 0;}
public void cal(int x,int z){}
public viod cal(int z,int y,int x){}
第23题:
7
8
10
12