Three major features of Java: encapsulation, inheritance, polymorphism

Source: Internet
Author: User

First, Package:

  internal can encapsulate their own implementation details, so that the information is hidden from other categories of destruction;

   The division of labor between the various classes is clear, other classes do not need to care about the implementation details, class changes in the details, other classes do not need to make changes;

Second, Inherit:

Derive new classes from existing classes in order to achieve the purpose of function and attribute extension, make it easy to expand, the hierarchy between classes clear, code highly reusable;

Three, polymorphic:

System A calls the system b,b provides several ways to service A, all of which are transparent to a;

The technique of implementing polymorphism: Dynamic binding, which refers to the actual type of the referenced object during execution, calls its corresponding method according to its actual type.

There are three prerequisites for polymorphic existence: inheritance, overrides, parent-class references to child-class objects.

Benefit: Eliminate the coupling between types and facilitate flexible invocation.

Three major features of Java: encapsulation, inheritance, polymorphism

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.