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

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).
主站蜘蛛池模板: 辽宁省| 乌拉特中旗| 星座| 安阳市| 新乡市| 岳西县| 靖宇县| 正蓝旗| 香格里拉县| 彩票| 保定市| 耿马| 栾城县| 炉霍县| 衡阳市| 南陵县| 武安市| 瓮安县| 郧西县| 达拉特旗| 奇台县| 辉县市| 乐昌市| 绥中县| 神农架林区| 方正县| 海口市| 托里县| 清苑县| 新乐市| 瓦房店市| 巴东县| 奉节县| 工布江达县| 海城市| 平阳县| 尤溪县| 娄烦县| 颍上县| 七台河市| 高唐县|