Consider the following code:
class Base
{
public void amethod(double d)
{
System.out.println("Base Method");
}
public static void main(
String [] args)
{
Base o = new Derived();
o.amethod(10);
}
}
class Derived extends Base
{
public void amethod(int i)
{
System.out.println("Derived Method");
}
}
It prints out "Base Method" instead of "Derived Method"! Can anyone explain why this is happening?