Java SUPER

Is SUPER a keyword or method? Explain Why?

Questions by d.yadagiri

Showing Answers 1 - 22 of 22 Answers

shekarGeek

  • Nov 5th, 2009
 

Super is a keyword which is used to execute an overridden method in the super class.

With super(), the superclass no-argument constructor is called.
-----------------------------------------------------------------------------------------
class a
{
     m1()
     {
          sop("Super Class");
     
     }
}

class b extends a
{
     m1()
     {
          super.m1();
          sop("Sub Class");

     }
     public static void main(String[] args)
     {
         b b1 =new b();
         b1.m1();
      }
}

O/P is:
Super Class
Sub Class
-----------------------------------------------------------------------------------------
Wth super(parameter list), the superclass constructor with a matching parameter list is called.


For example:

class a
{
     m1(p1,p2)
     {
          //LOGIC
    
     }
}

class b extends a
{
     m1(p1,p2)
     {
          super.m1(p1,p2);
     }
     public static void main(String[] args)
     {
         b b1 =new b();
         b1.m1(p1,p2);
  }

}

Yup SUPER is one of a keyword in Java...

this is basically used to concern Base class variables(Member's) & Functions(Method's)
in derived one class...


This Feature is only supported by JAVA not avlbl in C++.

Karthikgayu

  • Apr 25th, 2010
 

Yes, super is a keyword.
Super is used to call the method in the base class which is same as in the child class.

This is an example of run-time polymorphism. Occurs in method overridden .

mpcreddy

  • May 18th, 2010
 

Super is a keyword, it is not a method, it never works under static class.
whenever we extends class from base class there is possbility of getting same feature in to the derived class. In that situation JVM gets ambiguity to call the methods to avoid ambiguity SUN Microsystems provided keyword called Super.

Narsi Reddy

  • Apr 29th, 2011
 

super is a keyword in Java because it is defined as keyword in java and super is not a keyword or variable which belongs to any class.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions