Meaning of an abstract class

Source: Internet
Author: User

Meaning of an abstract class

Abstract meaning: For CodeMaintenanceAndReuse.

Abstract classes are often used to represent the abstract concepts obtained from the analysis and design of problem domains. They are the abstraction of a series of seemingly different but essentially identical specific concepts. The specific analysis is as follows:

1. Because an abstract class cannot instantiate an object, you must have a subclass to implement it before using it. In this way, components with the same attributes and methods can be abstracted to facilitate code and program maintenance.

For example, undergraduate and graduate students can be abstracted into students. They have the same attributes and methods. In this way, when you modify a class, it will be restricted by the parent class. This will remind developers that some items cannot be modified at will, in this way, we can impose unified restrictions on important things, which is also a kind of protection and will be of great help to maintenance.
2. When another similar component is generated, you only need to implement this abstract class to obtain the attributes and methods of this abstract class.
For example, if the school has new students such as junior college students, the junior college students directly inherit the students and then supplement their own attributes and methods. This is a good embodiment of code reuse.

Therefore, abstract classes in Java are very helpful for code maintenance and reuse, and are also an important embodiment of Java 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.