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

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).
主站蜘蛛池模板: 南漳县| 乌拉特中旗| 彝良县| 从江县| 新野县| 卢湾区| 铁岭县| 买车| 溆浦县| 花莲县| 徐水县| 北票市| 渭源县| 天水市| 思茅市| 双辽市| 上饶县| 玉山县| 同江市| 休宁县| 龙井市| 海门市| 繁峙县| 娱乐| 岳普湖县| 桓仁| 阜宁县| 惠安县| 新昌县| 东乌珠穆沁旗| 岳阳县| 吕梁市| 阜新市| 崇左市| 根河市| 澳门| 垫江县| 盐源县| 武穴市| 灵丘县| 岳池县|