1, object-oriented has three major characteristics, namely: encapsulation, inheritance and polymorphism.
2, Encapsulation: Object-oriented encapsulation is to describe the properties of an object and the behavior of the code encapsulated in a class, some properties are not intended to be public, or be accessed by other objects, so we use private to decorate the property, so that it is hidden; a method (decorated with public) is provided in the class. Commonly used is get, set method, you can manipulate these hidden properties, other classes can call these methods, change the value of hidden properties!
Encapsulation is to ensure that the software components have good modularity, the goal of the package is to achieve the "high cohesion, low coupling" software components, to prevent program interdependence and the impact of the changes. In object-oriented programming languages, objects are the most basic unit of encapsulation, and object-oriented encapsulation is clearer and more powerful than traditional language encapsulation.
3, inheritance: In the definition and implementation of a class, you can be on the basis of an existing class, using the extends keyword implementation of inheritance, subclasses can add a number of new content, or modify the original method to make it more suitable for special needs, which is inheritance. Inheritance is the mechanism by which subclasses automatically share the parent data and methods, which is a relationship between classes, which improves the reusability and extensibility of the software.
4, Polymorphic: Polymorphism is the use of the parent class at the time of declaration, the implementation or invocation of the use of specific subclasses, that is, do not modify the program code can be changed when the program is bound to run the specific code, so that the program can choose multiple running state, which is polymorphism, polymorphic enhanced software flexibility and extensibility. Here is an example, for example, when declaring an animal class, invoking a cat class (a subclass of an animal class), and actually performing a cat-eating method when the animal in the parent class is used.
A brief introduction to Java three major features