本帖最后由 007lzg 于 2012-7-2 18:12 编辑
abstract class Student
{
public abstract void study();
public void sleep()
{
System.out.println("躺着睡觉");
}
}
class DoStudent
{
public void doSome(Student stu)
{
stu.study();
stu.sleep();
}
}
class BaseStudent extends Student
{
public void study()
{
System.out.println("base study");
}
public void sleep()
{
System.out.println("坐着睡觉");
}
}
class AdvanceStudent extends Student
{
public void study()
{
System.out.println("advance study");
}
}
class DuoTaiDemo2
{
public static void main(String[] args)
{
DoStudent ds=new DoStudent();
ds.doSome(new BaseStudent());
ds.doSome(new AdvanceStudent());
}
} |
|