OverLoading !!!

Hi,

I am getting confused about the following FAQ...Please can

anyone explain the given answer(D) is right ?

Q4. Consider these classes, defined in separate source files,

public class Test1{

public float aMethod(float a, float b) throws IOException{

}

}

public class Test2 extends Test1{

}

Which of the following methods would be legal at line 2 in class Test2?

A.float aMethod(float a, float b){}

B.public int aMethod(int a, int b) throws Exception{ }

C.public float aMethod(float a, float b) throws Exception{ }

D.public float aMethod(float p, float q){ }

Correct Answer: B,D

Explanation:

B and D are correct. B is legal as it is an example of method overloading.

A is illegal because it is less accessible than the original method, because method in Test1 is public. And for any overriding method, accessibility must not be more restricted than the original method.

C is illegal because for overriding method, it must not throw checked exception ofclassess that are not possible for the origincal classes

[1166 byte] By [jaban_10a] at [2007-10-3 3:10:03]
# 1
I didn't understand your question. What exactly is confusing you here?
JoachimSauera at 2007-7-14 21:00:48 > top of Java-index,Java Essentials,New To Java...
# 2
whyC is not incorrect ?
jaban_10a at 2007-7-14 21:00:48 > top of Java-index,Java Essentials,New To Java...
# 3
Hi, C is in correct because ,Ans B is over loading and C Trying to over Riding .Over Riding must follow the same parameters and exception types Regards,R.Jagan
jaganrathinama at 2007-7-14 21:00:48 > top of Java-index,Java Essentials,New To Java...