日期:2014-05-20  浏览次数:20707 次

大家看看 这题的答案是?
4、类Test1、Test2定义如下:
1.public class Test1 {
2. public float aMethod(float a,float b)throws IOException {
3. }
4. }
5. public class Test2 extends Test1{
6.
7. }
将以下哪种方法插入行6是不合法的。(BCD)考继承和异常之间的知识
A. float aMethod(float a,float b){ } //不是方法重写 默认修饰符 缩小范围啦
B. public int aMethod(int a,int b)throws Exception{ }
C. public float aMethod(float p,float q){ }
D. public int aMethod(int a,int b)throws IOException{ }


尽量说详细点 谢谢大家啦!!


------解决方案--------------------
用eclipse测试 只有A不对 =。=
------解决方案--------------------
A 如你所说 缩小范围 ,在重写中缩小范围是不允许的
B 不是重写,合法
C 重写合法,规定父类没抛的异常子类也不能抛,但没规定父类抛出的子类一定要抛
D 不是重写,合法
------解决方案--------------------
楼上正解