Core JAVA Learning articles in-depth understanding of objects and classes

Source: Internet
Author: User

I. Object-oriented overview

1. Object-oriented Programming (OOP):

(1) consists of objects, each containing a specific functional part that is exposed to the user, and a hidden implementation part.

(2) If the object satisfies the requirement, it is not necessary to care about the implementation of its function.

(3) different from structured programming:

Structured programming: algorithms + data structures = Programs; The algorithm is first, and the data structure is second. The programmer first determines how the data is manipulated and then determines how the data is organized.

Object-oriented Programming: data structures + algorithms = Oop;oop The data structure in the first place, how to accurately implement, the real world of things abstract? How do you design a data structure that stores attributes of abstract things? The second is to consider the operation of data, to provide users with how, open and flexible methods.

Two. Java class overview

1. Class

(1) class, template for building objects.

(2) The process of building an object, called creating an instantiation of a class.

(3) The instance field, the data in the object.

(4) method, the process of manipulating the data.

(5) encapsulation, one of the important features of object-oriented programming. The key to implementing encapsulation is that the methods in the class are absolutely not allowed to access the instance domains of other classes directly. Encapsulation gives the object "black box" characteristics, which is the key to improve reusability and reliability.

(6) The extension of the class, with the expanded new class having all the properties and methods of the extended class. The process of class extension is called inheritance, followed by detailed description.

Three. Objects

1. Main features of the object:

(1) Object behavior: What actions can be applied to an object, or what methods can be applied to an object?

(2) The state of an object: How does the object method respond when those methods are applied?

(3) Object ID: How do you identify different objects that have the same behavior and status?

2. In-depth understanding:

(1) For all objects of the same class, the behavior of the object is defined by a callable method because it supports the same behavior and has familial similarity.

(2) Each object is stored, describing the current characteristics of the information, this is the state of the object, the state of the object changes, will change, but generally not spontaneous, the change of the state of the object must be implemented by invoking the method. If you change the state of an object without adjusting the usage method, the encapsulation is compromised.

(3) The state of an object does not fully describe an object. Each object has a unique identity.

(4) The key characteristics of the object are influenced by each other.

Four. The relationship between classes and classes

1. Dependence:

That is, "uses-a", if the method of one class manipulates an object of another class, it is said that one class depends on the other class.

2. Aggregation:

That is, "has-a", the aggregation relationship means that the object of Class A contains the object of Class B.

3. Inheritance:

namely "Is-a", object-oriented important concept, follow-up analysis.

Core JAVA Learning articles in-depth understanding of objects and classes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.