Interfaces and classes in Java

Source: Internet
Author: User

1, the interface from the user's perspective (using the implementation of the code) to see the problem.

2. An interface is a contract that is enforced by the compiler to collaborate between modules.

3, no member variable.

4, the member function can only declare cannot be implemented, (the default method in jdk1.8 can have method body).

The difference between an interface and an abstract class:

1. Abstract classes can have member variables,

2, can have partial realization;

3, abstract class can not be multiple inheritance, interface May;

4, the use of abstract class is the use of inheritance, but only single inheritance, and the interface is implemented using the implementation of the way, and can be implemented in multiple ways;

5, from the user's point of view, emphasizing the contract, forced collaboration between the two sides can not make mistakes.

Interfaces and classes in Java

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.