/**3:用抽象类的形式把下面的内容代码化
具体事物:基本班学员,就业班学员
共性:姓名,学习,休假
*/
abstract class Student1
{
private String name;
Student1(String name){
this.name=name;
}
public abstract void study();
public void sleep(){
System.out.println("都是宅男啊!");
}
}
class JiChu extends Student1
{
JiChu(String name){
super(name);
}
public void study(){
System.out.println("学习基础知识");
}
}
class jiuye extends Student1
{
jiuye(String name){
super(name);
}
public void study(){
System.out.println("学习就业班的知识");
}
}
class AbstractDome2
{
public static void main(String[] args)
{
JiChu jc=new JiChu("xiaoming");
jc.sleep();
jc.study();
jiuye jy=new jiuye("xiaoli");
jy.sleep();
jy.study();
}
} |
|