A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 980344791 中级黑马   /  2014-10-10 23:37  /  1125 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

选项中哪一行代码可以替换题目中//add code here而不产生编译错误?(  )

public abstract class MyClass {

           public int constInt = 5;

           //add code here

           public void method() {

               }

}

A)public abstract void method(int a);

B)value = value + 5;

C)public int method();

D)public abstract void anotherMethod() {}
为什么选A?谢谢。

1 个回复

倒序浏览
B 中vlaue没有定义,所以报错
c 中method会出现重定义的错误,因为函数的形参列表和返回类型、函数名都与下面的函数一样
      public void method() {

               }
D 中public abstract void anotherMethod() {} 。anotherMethod函数定义了abstract抽象,所以不能有实现,也就是不能有{}

所以a是正确答案,因为形参不一样,所以是函数重载。所以不会报错

评分

参与人数 1技术分 +1 收起 理由
敏敏好学 + 1

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马