objects with state and behavior in oop

后端 未结 4 489
渐次进展
渐次进展 2021-02-04 05:14

I keep hearing the term object has behavior and state or just one of them. But what is the difference or what does it mean, and if anyone can give an example I would really appr

4条回答
  •  春和景丽
    2021-02-04 05:27

    • Lamp is an object.
    • The "state" in lamp:on and off.
    • The "behavior" in lamp:turn on and turn off.

    In programming you declare states in "fields" and behaviors in "methods" etc..

    Read and learn object-oriented.

提交回复
热议问题