Originally posted by souji nutak:
Can we override a final private method???
class Base
{
final private void amethod(int iBase)
{
System.out.println("Base.amethod");
}
}
class Over extends Base
{
public static void main(String argv[])
{
Over o = new Over();
Base b = new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver)
{
System.out.println("Over.amethod");
}
}
I feel I didnt explain properly. So writing again.
Any private method cannot be inherited. So, there is no question of overridding. Second thing is, since a subclass cannot inherit private method i.e amethod, it can always redefine amethod.