---
title: "java之继承"
author: "yoyo08"
date: "2010-01-13T20:03:06Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2010-01-13T20:03:06Z"
id: 569543
url: "https://yoyo08.iteye.com/blog/569543"
---

如下面代码：

 

```
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
```