Java foundation - the three characteristics of object-oriented

There are three characteristics of object-oriented inheritance, polymorphism and encapsulation.

  (1) Inheritance: Inheritance is linked hierarchical model of class and class allow and encourage reuse, it provides a clearly stated in common. A new class of objects can be derived from existing classes, this process is called class inheritance. The new class inherits the properties of the original class, the new class known as the original class of the derived class (subclass), while the original class is called the base class for the new class (parent class). A derived class can inherit methods and instance variables of the base class from where it, and the subclass can modify or add new method makes it more suitable for particular needs.

  (2) Package: a package refers to the objective things into classes, each class to implement the protection of its own data and methods. Class can put their data and methods allow only trusted class or object manipulation of unreliable information hiding.

  (3) Polymorphism: polymorphism refers to allow objects of different classes respond to the same message. Compile-time polymorphism include polymorphism and polymorphic operation. Compile-time polymorphism is achieved by overload (Overload), by rewriting polymorphism (Override) runtime implementation. Polymorphism flexible language, abstract, behavior sharing and code-sharing advantages of a good solution to the problem of the application method of the same name.

Guess you like

Origin www.cnblogs.com/myl0205/p/11371699.html