What is the use of super?

Questions by sripri   answers by sripri

Showing Answers 1 - 3 of 3 Answers

Santhiya

  • Aug 8th, 2007
 

Use the super keyword to call the superclass implementation of the current method.

Satya

  • Mar 11th, 2013
 

Super is used to call the parent classes initialize method from the childs initialize method. super has following forms of implementation.
1. Calling only the super means, call the parents initialize method by passing all the parameters passed to childs initialize method that are passed when new is called.

2. Calling the super with brackets i.e., super(), calls the parents initialize method by not passing any parameters.

3. Calling super(x, y) with specific arguments, calls the parents initialize method by passing parameters that are needed from the childs initialize method. The order and no. of parameters passed is maintained. see examples

Code
  1. span style="font-style: italic;">#initialize to Parent#initialize.

  2. #initialize from Child#initialize

  Was this answer useful?  Yes

Venus Jain

  • Aug 22nd, 2017
 

To call the method from Parent 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