I have a question about the super variable in java. I understand that it is used to call the parent class constructor from the child class and access methods of the parent class but I have a couple of questions about this. Firstly I was always under the impression that when a method or constructor was called then we had to send arguments that were stored in the parameters of the constructor or method. When we call the method using the Super constructor we just send the variables which have not been initialized. Secondly I looked up the definition of the Super variable and found this : 'The super keyword in java is a reference variable which is used to refer immediate parent class object.' What exactly does this mean?
Though, your question does not seems to be much clear but i believe that you are confused with super keyword .
Take a look at the below lines i had written for the usage of super keyword.
Let's say a class Father has one default constructor and three methods (non static method A, non static method B and static method C). Class Son extends the class Father and overrides method A of Father. Father and son shares inheritance relationship.
So, if you can read definition of super keyword and read the examples i have given for the usage of super keyword then i hope it should be clear.
Though, if you still unclear about any scenario then please feel free to comment them down.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.