官术网_书友最值得收藏!

Objects and classes

Objects are the main elements of an object-oriented programming (OOP) language. An object holds both the state and the behavior.

If we think of classes as a template, objects are the implementation of the template. For example, if human is a class that defines the behavior and properties that a human being can have, you and I are objects of this human class, as we have fulfilled all the requirements of being a human. Or, if we think of car as a class, a particular Honda Civic car will be an object of this class. It will fulfill all the properties and behaviors that a car has, such as it has an engine, a steering wheel, headlights, and so on, and it has behaviors of moving forward, moving backward, and so on. We can see how the object-oriented paradigm can relate to the real world. Almost everything in the real world can be thought of in terms of classes and objects, hence it makes OOP effortless and popular.

Object-oriented programming is based on four fundamental principles:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism (subtyping polymorphism).
主站蜘蛛池模板: 鲁甸县| 确山县| 商洛市| 象山县| 黄大仙区| 栾川县| 东辽县| 昔阳县| 涿鹿县| 昭通市| 三门县| 隆德县| 邓州市| 星座| 盈江县| 卢氏县| 治多县| 五台县| 宝丰县| 紫金县| 宜宾市| 内丘县| 高青县| 赤壁市| 隆子县| 读书| 舒城县| 兴义市| 石泉县| 乌恰县| 衡水市| 岳阳县| 若尔盖县| 青铜峡市| 伊吾县| 阳江市| 汽车| 贵德县| 铜梁县| 太康县| 静安区|