package com.huxin.test.overvide;
public class OverrideTest {
public static void main(String[] args) {
Son son = new Son();
// 结果是:father中a的方法 son中b的方法
}
}
class Father{
public Father(){
//c(); 这样会报错哦
a();
b();
}
private void a(){
System.out.println("father中a的方法");
}
public void b(){
System.out.println("father中b的方法");
}
}
class Son extends Father{
public Son(){
}
private void a(){
System.out.println("son中a的方法");
}
public void b(){
System.out.println("son中b的方法");
}
public void c(){
System.out.println("son中c的方法");
}
}