询问一道模拟题

corner corner 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Given:
1. class BaseClass{
2. private float x= 1.0f;
3. protected void setVar (float f) {x = f;}
4. }
5. class SubClass exyends BaseClass {
6. private float x = 2.0f;
7. //insert code here
8. }
Which two are valid examples of method overriding? (Choose Two)
A. void setVar(float f) {x = f;}
B. public void setVar(int f) {x = f;}
C. public void setVar(float f) {x = f;}
D. public double setVar(float f) {x = f;}
E. public final void setVar(float f) {x = f;}
F. protected float setVar() {x=3.0f; return 3.0f; }

Answer:C,E
请问为什么A不对啊?A的声明就是protected吧?
...全文
评论 4
收藏 已收藏
分享
返回顶部
corner
Java 51,407 成员 86,132 内容