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

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).
主站蜘蛛池模板: 隆昌县| 毕节市| 区。| 池州市| 长沙县| 武功县| 万盛区| 北流市| 徐闻县| 武定县| 页游| 台南市| 呈贡县| 大关县| 双江| 正阳县| 柳河县| 抚顺市| 抚顺县| 措勤县| 山阳县| 溆浦县| 昔阳县| 司法| 栾城县| 东辽县| 建德市| 九江市| 客服| 自贡市| 莒南县| 吐鲁番市| 乳源| 宣化县| 临西县| 泰州市| 龙南县| 油尖旺区| 津南区| 时尚| 米林县|