Fundamentals of object-oriented programming
? Object
Object objects are a collection of variables and related methods, where variables indicate the state of an object, and methods indicate the behavior of the object.
Objects are content such as stateful (data) and behavior (functions) . For example, to illustrate a student who needs to provide a name, school number, date of birth, profession, interest, and so on, these data elements used to describe an object are called object properties. and the students ' behavior will include registration, elective courses, examinations, etc. A representation of an object's possible actions is called the behavior (or operation, method) of the object.
? Class
Classes define variables and methods common to a class of objects. instantiating a class produces an object of that class.
A class is an abstraction of an object of the same type, and an object is an instantiation of a class. For example, a yellow pen, a black pen, etc. can be abstracted out of the pen class. The class defines the data structure of each object belonging to the class (that is, the properties or member variables of the class) and the actions or methods that are performed by those objects (that is, the member methods or actions of the class). For example, a person as a research object, its characteristics include age, height, weight, etc., which can be regarded as the properties of the object. Human behavior as the object of the dynamic characteristics can be seen as the object of the member methods, such as eating, sleep.
? News
Objects must interact to implement complex behavior, providing information in the form of message messages, including: Receivers, methods, parameters.
Object-oriented features
? Packaging
One of the core ideas of object-oriented programming is to encapsulate the data and the operation of the data. By abstracting, the common properties are drawn from specific instances to form general concepts (i.e., classes).
? Inherited
Inheritance embodies an advanced programming model. Subclasses can inherit the properties and functionality of the parent class, which inherits the data and data that the parent class has, increases the data and data that is unique to the subclass, and modifies the data and operations on the parent class.
? Polymorphic
Polymorphism is another important feature of object-oriented programming. For example, the class teacher asked the whole class to clean up, while in the implementation of cleaning tasks, some people sweep the floor, someone watering, someone wiped glass. From the software point of view, polymorphism refers to the same operation name, but the implementation of different functions. The area () method can be used in the same area (), but depending on the parameters accepted by the operation, it is possible to calculate the size of the circle, the area of the rectangle, etc. Java uses methods such as overlay, method overloading, interface and other techniques to achieve this polymorphism.
Java objects, classes, messages, and attributes