类A有3个int型成员变量a、b、c,则( )是类A的正确构造方法。
A: void A(){a=0; b=0; c=0; }
B: public void A(){ a=0; b=0; c=0;}
C: public int A (int x, int y, int z){ a=x; b=y; c=z; }
D: public A(int x,int y, int z) { a=x; b=y; c=z; }
A: void A(){a=0; b=0; c=0; }
B: public void A(){ a=0; b=0; c=0;}
C: public int A (int x, int y, int z){ a=x; b=y; c=z; }
D: public A(int x,int y, int z) { a=x; b=y; c=z; }
举一反三
- 中国大学MOOC: 34. 下面是类MyClass的定义,对定义中各语句描述正确的是____。class MyClass{ public: void MyClass(int a){ X=a;} //① int f(int a,int b) //② { X=a; Y=b; } int f(int a,int b,int c=0) //③ { X=a; Y=b; } int f(int a,int b,int c=0) { X=a; Y=b; Z=c; } static void g(){ X=10;} //④ private: int X,Y,Z; };
- 仔细阅读程序,确定a,z的值? public class Example16{ public static void main(String[] args) { int x = 0; int y = 0; int z = 0; boolean a; a = x == 0 || z++ >1; System.out.println("a = " + a); System.out.println("z = " + z); } }
- 有以下定义: class Box{ int width,length,height; public: void set(int x=0,int y=0,int z=0) {width=x;length=y;height=z;} }; Box *box; 则以下哪种使用是正确的___
- 以下选项错误的是 A.main() { int x,y,z; x=0;y=x-1; z=x+y;} B.main() { int x,y,z; x=0,y=x+1; z=x+y;} C.main() { int x;int int y; x=0,y=x+1; z=x+y;} D.main() { int x,y,z; x=0;y=x+1; z=x+y,}
- 中国大学MOOC: 定义类A如下:class A{ int a,b,c; public void B(int x,int y, int z){ a=x;b=y;c=z;}}