One of the answer in a mock exam for
Legal reuse of method names:
-In subclass with same arguments with different return types.
I dont think that it is correct answer. I tried a sample code which gives a compile time error:
<CODE>
public class Q8 {
public int amethod()
{
return -1;
}
}
class Q9 extends Q8
{
public
String amethod()
{
return "Not Possible";
}
}
</CODE>
Q8.java:17: The method java.lang.String amethod() declared in class Q9 cannot override the method of the same signature declared in class Q8. They must have the same return type.
Any suggestions?