Write a program in java to demonstrate super keyword as a first statement?

class Pc

{

                public Pc()

                {

                                System.out.println("Pc Hello");

                }

                public Pc(int x)

                {

                                System.out.println("Pc Hiii");

                }

}

class Cat extends Pc

{

                public Cat()

                {

                                super();

                                System.out.println("Cat Hello");

                }

                public Cat(int x)

                {

                                super(x);

                                System.out.println("Cat Hiii");

                }

                public static void main(String arg[])

                {

                                new Cat();

                                new Cat(7);

                }

}

Super keyword as a first statement.PNG

, , , , , , ,

Leave a Reply