Hi Everyone,
I'm trying to practice some inheritance concepts and I'm stumped here.
I'm bad at explaining stuff, so I'll try to illustrate.
Here's the code of three classes:
I'm wondering why when I run it, the Subclass2 super.print() method returns two zeros instead of 1 & 2.
When I did a debug, I noticed that when obj.print() was ran in SubClass1, the private instance variables in superclass immediately becomes zero.
Can anyone explain this please? Thanks!