1、子类方法的访问控制范围不能小于基类
exam:
基类:
public class grandpa implements family {
public void eat(){
System.out.println("grandpa eat!");
}
public void eat(String s) {
// TODO Auto-generated method stub
}
}
子类:
class father extends grandpa {
public void eat()
{
System.out.println("father eat");
}
void eat(String s){ //这就有错误 应该为 public void eat(String s){
System.out.println(s);
}
}
2、子类必须实现所有基类(或者叫父类,超类)的方法;
3、子类可以重写父类的方法;
4、子类可以添加其他的方法来完成特性功能。