一个小问题,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/22 06:25:58
插入哪个选项不会导致编译错误
interface Myconstants{
int r =42;
int s=69;
int Area;
//插入代码 }

1.final double c=2*Math.PI*r;
2.int total=total+r+s;
3.int Area=r*s;
4.public static MAIN=15;
5.protected int CODE=31337;
我选1 3 5,
5不对吗?

你的代码本来就不对,int Area未初始化,现在假设你的代码是正确的来解题:
只有1是对的
错误原因:
2右边的total未定义
3Area重复定义
4没有声明变量的类型
5在Interface中的的修饰符只能是public,final,static

1错
2不知道
3对
4应该错
5应该不错

实在不知道 放到程序里运行下就ok了