Overriding a super class's instance variables

后端 未结 9 1920
暗喜
暗喜 2020-11-30 07:47

Why are we not able to override an instance variable of a super class in a subclass?

9条回答
  •  天命终不由人
    2020-11-30 08:00

    Because if you changed the implementation of a data member it would quite possibly break the superclass (imagine changing a superclass's data member from a float to a String).

提交回复
热议问题