Which two are valid examples of method overriding?()
A: float getVar() {return x:}
B: public float getVar() {return x; }
C: public double getVar() {return x; }
D: protected float getVar() {return x; }
E: public float getVar(float f) {return f;}
A: float getVar() {return x:}
B: public float getVar() {return x; }
C: public double getVar() {return x; }
D: protected float getVar() {return x; }
E: public float getVar(float f) {return f;}
举一反三
- Which two are void examples of method overriding? () A: void setVar(float f) { x = f;} B: public void setVar(int f) { x =f;} C: public void setVar(float f) {return f;} D: public double setVar(float f) {return f;} E: protected float setVar() { x = 3.0f; return 3.0f; }
- 下面函数定义正确的是_____。 A: float fun(float x; float y){ return x*y;} B: float fun(float x, y){ return x*y;} C: float fun(x,y){ int x,y; return x*y;} D: float fun( int x, int y){ return x*y; }
- 以下函数定义中,正确的是( ). A: float fun(float x,y){ ... return x+y;} B: float fun(int x,int y);{ ... return x+y;} C: int fun(float x,float y);{ ... return x+y;} D: float fun(float x,int y){ ... return x+y;}
- 判断下面的函数定义中错误的是: A: float volume(float x=1.0,float y=1.0,float z=1.0){return x*y*z;} B: float volume(float x,float y=1.0,float z) {return x*y*z;} C: float volume(float x,float y=1.0,float z=1.0) {return x*y*z;} D: float volume(float x,float y,float z) {return x*y*z;}
- float f(float x,int n){if(n==0) return 1;else return x*f(x , n-1);}main(){intn=5; float x=2.0;printf(〝%f〞,f(x,n)); } A: 16.00000 B: 8.00000 C: 32.00000 D: 64.00000