abstract class Student
{
public abstract void study();
public void sleep()
{
System.out.println("躺着睡");
}
}
class BaseStudent extends Student
{
public void study(){
System.out.println("Base study");
}
public void sleep()
{
System.out.println("座着睡");
}
}
class AdvStudent extends Student
{
public void study(){
System.out.println("adv study");
}
/*public void sleep()
{
System.out.println("站着睡");
}*/
}
class DoStudent
{
public void doSome(Student st)
{
st.study();
st.sleep();
}
}
public class riji84 {
public static void main(String[] args) {
BaseStudent bs =new BaseStudent();
bs.study();
bs.sleep();
AdvStudent as =new AdvStudent();
as.study();
as.sleep();
System.out.println("Hello world");
DoStudent ds=new DoStudent();
ds.doSome(new BaseStudent());
ds.doSome(new AdvStudent());
}
}
|