Oo. A.d.p

Source: Internet
Author: User

oo/a/d/pthree characteristics of objects and classesobject:

object is an extremely important feature of object-oriented language, and all object-oriented languages have common objects.

1. Responsibilities (Single)

2. Attributes (data, can be changed)

3. Functions (Behaviors, methods, business algorithms)

Summary: A complete object is to have attributes and behavior and its own responsibilities.

A complete object is a function that has attributes and behavior and its own.

class:

Any object needs to go through a design phase, and by design, it can describe the content of an object well, so the work of design is done by the class.

Thus, classes specifically design and describe features common to the same class of objects

Summary: Objects designed through a class can be executed in the JVM on the computer.

communication between objects:

Sometimes, a large task requires a lot of different objects to work together, and an object will need the function of another object to assist.

Creates an object---> invokes the object's method--Returns the result. This process is a communication

Package:

Hides the internal implementation details.

1. The package has encapsulated features that control access to the class.

2. Classes also have encapsulated attributes that control access to members (properties, behaviors).

3. The behavior itself also has encapsulated features that hide the implementation details of the feature.

are mainly controlled by access modifiers.

Inheritance:

The precondition of inheritance is to have the parent class, only inherit.

Inheritance is characterized by extracting the generality of subclasses and avoiding duplication.

Features of overloading and rewriting:

1. Rewrite

Can only occur between the parent and child classes, the method name, the return value type, the number of arguments, and the type must be the same, and the access modifier is greater than or equal to the level of the parent class.

Subclasses can override this method when the parent class inherits a method that does not satisfy the current business scenario.

2. Overloading

Can occur between a parent class and a subclass, or it can occur in this class. Requires the same method name, the method must have a different number and type of arguments, and there is no requirement for the return value and the access modifier

Polymorphic :

Polymorphism also occurs between a parent class and a subclass, or between an interface and an implementation class.

"Parent class type, child class object. Compile-time look at the parent class, run-time look at the child class "

Different subclasses, which can act as the role of their parent class in different business scenarios,

What you see is the type of the parent class.

Rewrite: belongs to run-time polymorphism. (determined at run time.) If the subclass has overridden, the overridden method is executed)

Overload: Belongs to compile-time polymorphism. (determined at compile time.) In the compilation phase, the explicit invocation is

Oo. A.d.p

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.