2. The difference between abstract classes and interfaces

Source: Internet
Author: User
The interface is public, there is no private method or variable, it is used for others to use,
and abstract classes can have private methods or private variables,
In addition, the implementation of the interface must be implemented in all the methods defined in the interface,
And the implementation of the abstract class can selectively rewrite the need to use the method, the general application, the most top-level interface, and then the abstract class implementation interface, finally to the concrete class implementation.

Also, an interface can implement multiple inheritance, and a class can inherit only one superclass, but it is possible to implement multiple inheritance by inheriting multiple interfaces, and the interface has the function of identifying (there are no methods, such as remote interfaces) and data sharing (the variables inside are all constants).

2. The difference between abstract classes and interfaces

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.