Because members variables never inherited and do not behave in polymorphic way.
Both the classes have variable with same name and you are assigning a child reference to parent object. So the instance member of the referring (Parent class) class will be called and method of the original underlying class (Child class) will be called.
there is one very simple rule about this: Methods are called based on object while static methods & members variables are called based on reference.
Now you wrote
here reference is of Mammal while object is of Zebra so
will call Mammal variable &
will call zebra noise method
Yep, for sure. I changed makeNoise() to static in both classes,
as demanded by the compiler, and the output became, "furry
generic noise." Mauricio Archbold Babroza, are you there?