1 5.8上机练习
当父类定义为final时子类重载该函数会出现报错
1 package FuZi; 2 3 public class People { 4 void a(){System.out.println("People");} 5 }
1 package FuZi; 2 3 public class Student extends People{ 4 void a(){System.out.println("Student");} 5 public static void main(String args[]){ 6 People p=new Student(); 7 p.a(); 8 } 9 10 }
当新建 People p=new Student();
当Student p=new People();
2 没什么问题
3 明天继续看手册