子类可以重写父类里的同名方法
1.2 规则
子类的访问范围必须大于等于父类的访问范围
1.3 实例
父类Animal.java
package com.geek99.demo;
public class Animal {
protected void run(){
System.out.println(" Animal run...");
}
}
子类Dog.java
package com.geek99.demo;
public class Animal {
protected void run(){
System.out.println(" Animal run...");
}
}
测试类Test.java
package com.geek99.demo;
public class Test {
public static void main(String[] args) {
Dog dog = new Dog();
dog.run();
}
}
该博客教程视频地址:http://geek99.com/node/1615