sumit kothalikar wrote:
i want to ask few questions o the above code
1) what is the use of super at line 1 why the output is DemoC# instead of DemoJava
super is used to invoke the super class members, such as, methods, instance variables. If you redefine the instance variables of the super class in your sub class, then you can invoke the super class members using super. But, here, even though, you've invoked with the super keyword, because, you've re-assigned the values for the instance variables, the re-assigned value will be there in the super class instance variable!
sumit kothalikar wrote:
2) what we are trying to access using super.s
As said earlier, the super class version of the instance variable s. But, you've re-assigned the value!
sumit kothalikar wrote:
3)why the output is same even though we use super.s ,this.s ,or s in println statement at line 1
I think, it should be clear now!