hi
When I compile the below code, I get ambiguity error because the compiler cannot make out which overloaded version of the method is being called. However, this ambiguity does not happen between the superclass versions of overloaded methods, if I instantiate the superclass instead of the subclass.
Whats the reason ?
class Tester
{
public int func(int x, int y){
return x+y;
}
public long func(long x, long y){
return x*y;
}
}
class NewTester extends Tester
{
public long func(long x, long y){
return (x/y); }
}
class
Test {
public static void main(
String args[])
{
NewTester t=new NewTester();
//Tester t=new Tester();
System.out.println(t.func(1,2));
}
}
Thanks
Deepti