package edu.xcdq.demo01;
public class Demo01 {
public static void main(String[] args) {
UncleOne uncleOne =new UncleOne();
uncleOne.faHongbao();
UncleTwo uncleTwo = new UncleTwo();
uncleTwo.faHongbao();
}
}
package edu.xcdq.demo01;
/*
abstract 抽象的
abstract 修饰的方法,在抽象类中只写方法的声明,不需实现
*/
//抽象类
public abstract class Uncle {
private String name;
private int age;
//抽象方法
public abstract void faHongbao();
}
package edu.xcdq.demo01;
import edu.xcdq.demo01.Uncle;
public class UncleOne extends Uncle {
public void faHongbao(){
System.out.println("大舅发红包,还送酒");
}
}
package edu.xcdq.demo01;
import edu.xcdq.demo01.Uncle;
public class UncleTwo extends Uncle {
public void faHongbao(){
System.out.println("二舅发红包,还哦是那个烟");
}
}