0

Can you please explain about 'this' and 'super' keywords?

with the help of an example

28th Mar 2017, 4:59 AM
Hemanth Sans
Hemanth Sans - avatar
2 Answers
+ 5
this keyword refers to the current object against which method has been invoked. It is preferably used inside method or constructor of class its data members within the method definition exclusively. Example class Point{ private int x; private int y; public void setPoint (int x, int y){ this.x = x; this.y = y; } super refers the the base class which has been inherited into a new class. It is used to call public methods and constructors defined in the super class class a{ public show(){ System.out.Println("I am super"); } } class b extends a { public show(){ super.show(); System.out.Println("I am junior"); } }
28th Mar 2017, 6:50 AM
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender)
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender) - avatar
+ 1
thank you mr.devendar
28th Mar 2017, 8:00 AM
Hemanth Sans
Hemanth Sans - avatar