Difference between super class and this Class..? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Difference between super class and this Class..?

Difference between super class and this Class..?

2nd Aug 2018, 1:53 AM
Ashok K
Ashok K - avatar
1 Answer
+ 1
this refers to the current instance whereas super refers to the parent instance... I mean if u have class A { public int a; } class B extends A { public int a; // If you have to call the int 'a' of A instead of B then you can write super.a = 5; // If you have to call the int 'a' of B instead of A then you can write this.a=7; } this assigns 7 to class B int 'a' & assigns 5 to class A int 'a'
2nd Aug 2018, 5:12 AM
Rishabh
Rishabh - avatar