What is a supertype method?

后端 未结 6 1321
情话喂你
情话喂你 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:50

    Super is used to invoke parent class Properties used at 3 levels variable constructer and method level

    1.Super at Variable

    class Super
    {
        int age;
        Super(int age)
        {
            this.age=age;
        }
            public void getAge()
            {
                System.out.println(age);
            }
    }
    class Sub extends Super
    {
        Sub(int age)
        {
            super(age);
        }
        public static void main(String[] args)
        {
             Super obj=new  Super(24);
             obj.getAge();
        }
    }
    

提交回复
热议问题