Java-three characteristics and design rules of object-oriented

Source: Internet
Author: User

1) Package:

1.1) Class: Encapsulates the properties and behavior of an object

1.2) Method: Encapsulation is the implementation of the specific business logic

1.3) Access control modifier: Encapsulated is access permission

2) Inheritance:

2.1) Function: Reuse of code

2.2) Parent class/base class: Common Properties and behaviors

Subclass/Derived classes: unique properties and behaviors

2.3) After the child inherits from the parent, the child has: Parent + child

2.4) transitive, single inheritance, multi-interface implementation

3) Polymorphism:

3.1) Meaning: Polymorphism of behavior, polymorphism of object

3.2) upward styling, forced type conversion, instanceof judgment

3.3) polymorphic forms of expression:

3.3.1) Rewrite: polymorphic according to Object

3.3.2) Overload: polymorphic According to parameters

Design Rules:

1) Abstract The attributes and behaviors common to all subclasses into the parent class

2) All sub-classes behave the same, designed as a common method

All subclasses behave differently and are designed as abstract methods

3) Abstract The behavior common to the partial subclasses into the port

Interface is used when compliance is both a principle

Interfaces are extensions to inherited uniqueness (multiple inheritance)

I am a beginner, if the update is not good, welcome the Great God pointed out, thank you!

More exciting after the update, reprinted annotated!

Java-three characteristics and design rules of object-oriented

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.