java的基础问题
(11)类Test1、Test2定义如下:
1. public class Test1
2.{ public float aMethod(float a,float b) throws
3. IOException { }
4. }
5. public class Test2 extends Test1{
6.
7.}
将以下哪种方法插入行6是不合法的。( B )
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{ }
请问这题为什么会选择C呢?我听了很多个人说是重载,可是我一直搞不懂因为,重载是同一个类里的方法相同参数列表不同,而我是认为是重写因为重写是发生在子类继承父类可以重写父类的方法的呀,所以这题应该是重写呀?可是是错的,答案是选C,的请问为什么呢?