package pkg;
//main
public class p163 {
public static void main(String[] args) {
new Gextend(5);
}
}
//*
class Gbase{
Gbase(){
System.out.println("Gbase() before invoking methods:");
method_public();//DYNAMIC
method_protect();//DYNAMIC
method_default();//DYNAMIC
method_static();
method_final();
method_private();
System.out.println("Gbase() after invoked methods");
}
public void method_public() {
System.out.println("Gbase.method_public()");
}
protected void method_protect() {
System.out.println("Gbase.method_protected()");
}
void method_default() {
System.out.println("Gbase.method_default()");
}
static void method_static() {
System.out.println("Gbase.method_static()");
}
final void method_final() {
System.out.println("Gbase.method_final()");
}
private void method_private() {//is final function
System.out.println("Gbase.method_private()
【JAVA学习路-think in java】p163:在子类对象生成时,基类构造器调用子类同名函数发生的意料之外的事
最新推荐文章于 2021-02-27 01:30:38 发布