Java abstraction, package, inheritance, and polymorphism understanding, java Polymorphism

Source: Internet
Author: User

Java abstraction, package, inheritance, and polymorphism understanding, java Polymorphism

1. abstraction, encapsulation, assembly, inheritance, and polymorphism are several major features of java object-oriented programming.

Abstraction: Abstraction refers to a transaction. We ignore what we don't care about, extract the attributes and actions we want, and extract them as code; for example, we need to abstract a student. We only care about his score, so we do not care about his height. We do not care whether the student eats with his left hand, we only care about whether or not he performs the test, so we only need to extract the score attributes and test behavior.

Encapsulation: Abstract behaviors and attributes must be saved together, and can be encapsulated as a class to provide external access interfaces.

Inheritance: inheritance can make the program more flexible and make the code more concise. Subclass inherits the parent class and can have the attributes and methods of the parent class. The parent class extracts the common attributes of the Child class.

Polymorphism: multiple states are displayed, and multiple selectivity is added. class inheritance is the medium withdrawal of polymorphism, and the method overload is also the medium withdrawal of polymorphism.

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.