Super In Java Homework Help
It is a reference variable used by java as reference of parent class object. It is derived from the inheritance concept. The parent class instance is implicitly created when an instance of child class is created.
Use of Super Keyword of Java:
Following are the basic three uses of java keyword of supper.
- Use with variables when both classes parent and child have the same variables
- Use with methods when both parent and child classes have same method name to avoid ambiguity for JVM.
- Use to access the constructor of a parent or super class in its child class. It may use with default constructor or parametric constructor.
Whenever we have to call the constructor or method or variable of parent class we have to call super function its desire child class. If there is no constructor of super class explicitly invoke the compiler of java insert the default no argument in parent constructor. This concept bring chaining of constructor. The basic function of this keyword super is to eliminate the ambiguity between parent and their child classes.