单项选择题

定义类A及类中的方法getVar(),定义类A的子类B,若要在类B中覆盖同名方法,下面正确的定义是?
 class A{ 
   private float x=1.0f; 
   protected float getVar(){  return x;  } 

class B extends A{ 
    private float x=2.0f; 
    //覆盖类A中的同名方法的代码放在此处
 }
A float getVar(){return x;}
B protected float getVar(float y){return x+y;}
C protected float getVar(){return x;}
D public float getVar(){return x;}

题目列表

你可能感兴趣的试题

问答题

下列诗句,不属于《春江花月夜》的是()

答案:

A.春江潮水连海平,海上明月共潮生

B.去来江口守空船,绕船月明江水寒
<...
微信扫码免费搜题