package day2_抽象类; /* * 基础班老湿,就业班老湿 * 共性 * 属性 姓名,年龄,性别 * 行为 讲课 */ public class AbstractTeacherTest { public static void main(String[] args) { BasicTeacher b = new BasicTeacher(); b.name = "风清扬"; b.teach(); } } abstract class Teacher2 { String name; int age; String gender;//性别 public abstract void teach(); } class BasicTeacher extends Teacher2 { @Override public void teach() { System.out.println(name + ":教授基础课程"); } }
输出