abstract关键词的使用与继承性
作者:互联网
package com.yby5;
public class AbstractTest {
public static void main(String[] args) {
Teacher1 p = new Teacher1();
p.teach();
p.ready();
}
}
//abstract的方法必须重写;
//类似于父类创建的虚拟方法,子类调用只需重写方法体。
abstract class Teacher0{
int id;
String name;
public abstract void ready();
public abstract void teach();
}
class Teacher1 extends Teacher0{
@Override
public void ready() {
System.out.println("正在备课1111");
}
@Override
public void teach() {
System.out.println("正在讲课2222");
}
}
标签:teach,abstract,关键词,public,Teacher1,ready,继承性,void 来源: https://blog.csdn.net/weixin_63566550/article/details/121781266