If i have 2 classes, Top and ClassB which extends Top
and create an instance of ClassB:
ClassB b = new ClassB();
my results are:
"variable value = variable is initialized in B Class"
Then if i change in ClassB -
String variable = null and run it gives me:
variable value = null
But my problem is when i dont have ClassB inheriting from Top and run with
String variable;
or
String variable = null;
both gives me output of
variable value = null
So what is happening when ClassB inherits from Top?
I know that the B constructor is calling super, so does that mean its calling setVariable (in Top?) but as its overridden in ClassB, then that is whats being called and setting the String variable?
I hope that makes sense