Interfaces and abstract classes

Source: Internet
Author: User

Interface Features

1. All methods are abstract

2. Properties are static

3. There can be multiple inheritance between interfaces. (equivalent to concentrating the requirements)

4. An inheritance relationship between interfaces

5. Classes and interfaces are implementation relationships

6. Interface-oriented programming to reduce coupling degree

-----------------------------Courseware Part---------------------------------------

The member modifiers in the interface are fixed.

Member constants: public static final

member functions: Public abstract

The members in the interface are public.

The appearance of the interface will show "multiple inheritance" through another form, that is, "multi-Implementation"

Features of the interface:

1. Interface is the rule of external exposure

2. Interface is the function extension of the program

3. The appearance of the interface reduces coupling

4. Interfaces can be used for multiple implementations

5. Classes and interfaces are implementation relationships, and classes can inherit one class and implement multiple interfaces at the same time

6. There can be an inheritance relationship between interface and interface


Abstract class features

1. The class in which the abstract method resides must be an abstract class

2. Abstract classes can have no abstract method


Interface and abstract class comparison

Commonality: Abstract concepts that are constantly extracted

Difference 1: Abstract class embodies inheritance relationship, a class can only inherit

Interface embodies the realization of the relationship, a class can be implemented more

Difference 2: Abstract classes are inherited, are "is a" relationships

Interfaces are implementations, which are "like a" relationships

Difference 3: A non-abstract method can be defined in an abstract class for the subclass to use directly

Interfaces are abstract, and members in an interface are fixed modifiers



Interfaces and abstract classes

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.