System.out.println("Animal breathe");
}
}

class Fish extends Animal...{
}

class Integration...{
public static void main(String[] args)...{
Animal an=new Animal();
Fish fh=new Fish();
an.breathe();
fh.height=33;
fh.breathe();
}
}

System.out.println("Animal breathe");
}
}

class Fish extends Animal...{
}

class Integration...{
public static void main(String[] args)...{
Animal an=new Animal();
Fish fh=new Fish();
an.breathe();
fh.height=33;
fh.breathe();
}
}

编译运行:

注意:上例程序中定义了三个类,我们编译时生成三个类文件,但是只有Integration类包含主函数,所以运行加载的是Integration类。
■ 方法的覆盖
方法的覆盖是针对基类与派生类而言的,而在同一个类中称为方法的重载。

class Animal...{
int height,weight;