Remove override Solution – 2: super keyword

Super keyword is second solution of remove override from java programs. Using of super keyword we can call super class methods and access super class variables.



class A


                void method()


                                System.out.println(“Welcome in A Class”);



class B extends A


                void method()   // Override


                                // Need Super keyword

                                //super.method();          // call to super class method()

                                System.out.println(“Welcome in B Class”);


                                super.method();              // call to super class method()



class inh6


                public static void main(String args[])


                                B b1 = new B();

                                b1.method();     // Call to B Class and override





Welcome in A

Welcome in B


About Programs.

In this program, both class A and B have same function method() with same parameter. When we call method() from main class, that time method of B class executed. From Sub class B, we use super.method(), this statement call to super class method().


Video available on YouTube.

Earn Money Online

413total visits,1visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.


Link back if you want.

Enter Captcha Here :*

Reload Image