What is commonly said in Java encapsulation, inheritance, polymorphism

Source: Internet
Author: User

1. Encapsulation

Hiding the state information of an object inside an object does not allow the external program to access the information inside the object directly, but rather through the methods provided by the class to implement operations and access to internal information, that is, the set and get methods.

There are two main meanings:

(1) Hide the hidden.

(2) exposing the exposure.

2. Inheritance

Subclasses inherit the behavior of the parent class.

3. polymorphic

There are two types of polymorphism in Java: Edit-time polymorphism and run-time polymorphism.

The polymorphism of the edits can be reflected in the overloads of the method. A method name can have different methods of entry, the method body is not the same, depending on the situation to achieve.

Run-time polymorphism means that the program can select multiple running states. A reference to the parent class of the child class. Upward transformation.

A is the parent B is the child

A a1=new b ();

This allows A1 to access only the methods and properties that are already in the parent class

And if the method that overrides the parent class in B must be executed, the method body of the subclass is used.

This is also the most important polymorphic explanation.

What is commonly said in 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.