Interfaces and abstract classes

Source: Internet
Author: User
Definition

An interface refers to an abstract object (which can be another entity) that provides itself to the outside world. It is used to separate external communication methods from internal operations, this allows it to be modified internally without affecting the interaction between other external entities, just as multi-Abstraction provided by object-oriented programming.

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.

Same

Both interfaces and abstract classes are source self-structured structures, both of which contain abstract methods and cannot generate instances.

Different
  • Abstract classes are the abstraction of objects, and interfaces are a type of behavior specification. For example, a man is a man and a man eats dinner. Here, the man is a subclass, the man is an abstract class, and the meal is an interface.
  • A class can inherit only one abstract class and can implement multiple interfaces.
  • Abstract classes can contain non-Abstract METHODS, constructors, and interfaces.
  • The member variables of the abstract class can be modified by different modifiers, and the default interface is the static constant static final. This feature is derived from the second point. Similarly, the interface method is static abstract by default.

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.