在子类中,若要调用父类中被覆盖的方法,可以使用super关键字

package text;

class Parent
{
    int x;
    public Parent()
    {
        
            System.out.println("Parent Created1");
      }
    public void show(){
        System.out.println("Parent Created2");
    }

}

class Child extends Parent
{
    int y;
    public Child()
     {
    
        System.out.println("Child Created1");

}
    public void show(){
        super.show();
        System.out.println("Parent Created3");
    }

}

public class text
{

public static void main(String args[])
     {

Child c = new Child();
    c.show();
  }

}

 

 

 

posted @ 2022-11-04 14:16  叫金克丝爆爆  阅读(124)  评论(0)    收藏  举报