posted 1 year ago
No, If you see here The formal parameters int a has value 1 and int b has 2 value passed by this code then in that constructor of second we have
Which assigns value of a i.e. 1 to instance variable i of super class first. Now we have i = 1 super is the keyword used to access field of super class, here instance variable int i of super class first.
But here on the same line We again assigned i = b where value of b is 2. Now value of i is 2.
After above assignments, we called to print() method which prints
So i and super.i both means same variable of class first which has value 2 so you get output i 2; super.i: 2
Emilian Chmiel wrote:when I run i I get:
i 2; super.i: 2
should't I get
i 1; super.i: 2