/*
具体事物:基本班学员,就业班学员
共性:姓名,学习,休假
父类:学员student 属性:姓名 方法:学习,休假
子类: 基础班BaseClass, 就业班WorkClass
*/
//测试类
class HeiMa
{
public static void main(String[] args)
{
BaseClass bc = new BaseClass();
bc.study();
bc.holiday();
System.out.println("Hello World!");
WorkClass wc = new WorkClass();
wc.study();
wc.holiday();
System.out.println("Hello World!");
}
}
//父类:学员student 属性:姓名 方法:学习,休假holiday
abstract class Student
{
private String name;
public void holiday()
{
System.out.println("学生有假期");
}
public abstract void study();
}
//子类基础班BaseClass
class BaseClass extends Student
{
public void study()
{
System.out.println("学习JAVA基础");
}
}
//子类就业班WorkClass
class WorkClass extends Student
{
public void study()
{
System.out.println("学习android");
}
}
|
|