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: 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; }
举一反三
- 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;}
- 下列程序中注释的那个代码是错误的? abstract class Takecare{ protected void speakHello() {} public abstract static void cry(); static int f(){return 0;} abstract float g(); } A: protected void speakHello() {} B: public abstract static void cry(); C: static int f(){return 0;} D: abstract float g();
- class MethodOverload{[br][/br]public void setValue(int a, int b, float c){}[br][/br]}[br][/br]下列哪个方法定义是setValue的重载方法: ( ) A: public void setValue(int a, int c, float b){} B: public void setVar(int a, int b){} C: public int setValue(int a, float c, int b){return a;} D: public float set (int a, int c, float b){return a;}
- 对于不需要返回值且有两个float形参的函数,下列有效的函数原型是()。 A: void f(float,float); B: f(float x,float y); C: void f(x,y); D: void f(float x,y);
- 下列函数的定义中正确的是( )。 A: void f(int x,y){ cout<<x+y<<endl; } B: void f(int x,int y){ return x+y; } C: int f(float x,float y){ return x+y; } D: int f(int x,int y){ cout<<x+y<<endl; }