class DuotaiDemo4
{
public static void main(String[] args)
{
People p = new People(" nokia asha");
p.show();
}
}
class God
{
private String name;
God(String name)
{
this.name = name;
}
void show()
{
System.out.println(name);
}
}
class People extends God
{
People(String name)
{
super(name);
}
void show()
{
super.show();
}
}
我用子类show方法覆盖了父类的show方法,再调用应该父类的应该报错呀??怎么结果还是 nokia asha 呢?
还是不懂这些方法在内存中的状态。。。求指教
|