Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: keyword super in java

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default keyword super in java

    Hello,

    what is super as a keyword in java and how can I use in the program?

    Thank you


  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: keyword super in java

    There are so many uses of super keyword.
    Used to refer immediate parent class instance variable.
    Used to invoke parent class constructor.

    class Parent{  
    Parent(){
    System.out.println("In Parent class constructor");
    }  
    }
     
    class Child extends Parent{  
    Child (){  
    super();//will invoke parent class constructor    
    }  
    public static void main(String args[]){  
    Child child =new Child ();  
    }  
    }

    and as it refer to immediate parent class instance variable so it also used to call a method of parent class.

    super.ParentClassMethod();

  3. The Following User Says Thank You to aprabhat For This Useful Post:

    shirin (December 27th, 2013)

Similar Threads

  1. Conceptual Questions Related To "super" keyword and "constructor".
    By wikki2013 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2013, 02:14 PM
  2. What is the use of enum keyword in java
    By vilkas in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 26th, 2012, 12:53 PM
  3. What is the use of enum keyword in java
    By vilkas in forum Java Theory & Questions
    Replies: 4
    Last Post: December 17th, 2012, 10:34 AM
  4. Super Keyword
    By shruthi in forum Java Theory & Questions
    Replies: 12
    Last Post: October 13th, 2011, 03:31 PM
  5. please help super new to Java
    By R.Rivera in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 13th, 2011, 07:58 PM