Overriding member variables in Java ( Variable Hiding)

前端 未结 12 943
小蘑菇
小蘑菇 2020-11-22 03:07

I am studying overriding member functions in JAVA and thought about experimenting with overriding member variables.

So, I defined classes

public clas         


        
12条回答
  •  伪装坚强ぢ
    2020-11-22 04:00

    Java has a feather of encapsulation means it tightly binds the property and the behavior of an object. so only via a class reference we can call it's behavior to change it's property.

    and in inheritance only method overrides so that it can affects only it's property.

提交回复
热议问题