What is a supertype method?

后端 未结 6 1314
情话喂你
情话喂你 2021-02-03 14:12

I have googled couple of times but still can\'t understand the supertype method. Can anyone please explain what is this?

6条回答
  •  隐瞒了意图╮
    2021-02-03 14:53

    Super at Constructer level

        class SuperClass
    {
        int num=10;
        public void display()
        {
            System.out.println("Superclass display method");
        }
    }
    class SubClass extends SuperClass
    {
        int num=20;
    
        public void display()
        {
            System.out.println("the value of subclass variable name:"+num);
            System.out.println("Subclass display method");
        }
            public void Mymethod()
            {
                super.display();
                System.out.println("the value of superclass variable name:"+super.num);
            }
            public static void main(String[] args)
            {
                SubClass obj=new SubClass();
                obj.Mymethod();
                obj.display();
            }
    }
    

提交回复
热议问题