如下面代码:
public class Test
{
public static void main(String[] args)
{
TestA ta = new TestC();
ta.show();
}
}
class TestA
{
public TestA()
{
System.out.println("TestA");
}
public void show()
{
System.out.println("TestA.show");
}
}
class TestB extends TestA
{
public TestB()
{
System.out.println("TestB");
}
public void show()
{
System.out.println("TestB.show");
}
}
class TestC extends TestB
{
public TestC()
{
System.out.println("TestC");
}
}
输出为:
TestA
TestB
TestC
TestB.show