over 9 years ago
Super Keyword
The super keyword in java is the one which is used to refer to the immediate base class members in the sub class.
Super Keyword can be used to invoke the constructor of the base class.
Whenever you create the object of the subclass, an instance of parent class is created automatically. which can be referred by the super keyword. It allows to access only the non-private members of the super-class.
syntax:
In the above code the super keyword is used to call the constructor of the super class. To access the methods of the base class using super keywords
Syntax is as :
this Keyword
The this keyword allows to refer current class methods/attributes with its private members. it is used to access the methods/attributes of the object. It invokes the current class methods and the constructor
The syntax to access the current current class constructor is as:
To access the other members like function or the variables of the same class we can use this keyword as :
over 9 years ago
Good One.
1 Comment(s)