本帖最后由 黄玉昆 于 2013-3-16 13:33 编辑
abstract class Student
{
abstract void study();
void sleep(){
System.out.println("should sleep");
}
}
class BaseStudent extends Student
{
void study()
{
System.out.println("baseStudy");
}
}
class AdvStudent extends Student
{
void study()
{
System.out.println("advStudy");
}
}
public class Study11{
public static void main(String[] args)
{
BaseStudent bs = new BaseStudent();
bs.study();
bs.sleep();
}
}
sleep方法不需要在子类中重写吗?还有这个程序中super存在吗? |