public class Uncle {
private String name;
private int age;
public Uncle(){
System.out.println("Uncle构造方法");
}
public void faHongbao(){
System.out.println("舅舅发红包");
}
}
public UncleOne(){
super();
System.out.println("uncleone的构造方法");
}
public void chouyan(){
System.out.println("大舅喜欢抽烟");
}
//方法的重写 覆写
public void faHongbao(){
System.out.println("大舅家道中落,发不起红包了,该送祝福了");
}
}
public class UncleTwo extends Uncle {
public void hejiiu(){
System.out.println("二舅喜欢喝酒");
}
public void faHongbao(){
System.out.println("二舅不仅发红包,还送茅台");
}
}
public class UncleOneSon extends UncleOne{
public UncleOneSon(){
super();
System.out.println("UncleOneSon的构造方法");
}
public void faHongbao(){
System.out.println("大舅的儿子厉害了,接着发红包");
}
}
public class Demo {
public static void main(String[] args) {
/* UncleOne uncleOne = new UncleOne();
uncleOne.faHongbao();
uncleOne.chouyan();
UncleTwo uncleTwo = new UncleTwo();
uncleTwo.faHongbao();
uncleTwo.hejiiu();*/
/* UncleOneSon uncleOneSon = new UncleOneSon();
uncleOneSon.faHongbao();
*/
new UncleOneSon();
}
}