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

在子类中,若要调用父类中被覆盖的方法,可以使用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 @ 2017-11-10 22:39  肥鹅PU火  阅读(2439)  评论(0编辑  收藏  举报