62,620
社区成员
发帖
与我相关
我的任务
分享
class Base {
protected void print() {
System.out.println("父类方法被调用");
}
public void show() {
this.print();
System.out.println(this.getClass().getName());
}
}
class Sub extends Base {
protected void print() {
System.out.println("子类方法被调用");
}
}
public class InheritanceDemo {
public static void main(String[] args) {
Sub s = new Sub();
s.show();
}
}