内存图:

示例代码:
package ljy.inheritance;
public class Animal extends Object {
String name;
Integer age;
public Animal() {
super();
}
public Animal(String name, Integer age) {
super();
this.name = name;
this.age = age;
}
void run(){
System.out.println("一只"+this.age+"岁的"+ this.name + "在奔跑!~~");
}
void sound(){
System.out.println("一只"+this.age+"岁的"+ this.name + "在吼叫!~~");
}
}
package ljy.inheritance;
public class Tiger extends Animal{
String furcolor;
public Tiger(String name,Integer age,String furcolor){
super(name,age);
this.furcolor = furcolor;
}
void hunt(){
System.out.println("一只"+this.furcolor+"的"+ this.name + "在捕猎!~~");
}
}
/**
*
*/
package ljy.inheritance;
/**
* @author fshxxxyydys
*
*/
public class Tester {
/**
* @param args
*/
public static void main(String[] args) {
Tiger t = new Tiger("东北虎",1,"白色");
//标配的引用指向可以是使用对象的所有功能
Animal a = new Tiger("东北虎",1,"白色");
Object o = new Tiger("东北虎",1,"白色");
//父类引用指向可以指向自己的子类对象
//Tiger t2 = new Animal("东北虎",1);
//子类引用指向如果指向父类对象会产生错误。
}
}