Using Java to implement object-oriented fourth chapter

Source: Internet
Author: User

Fourth chapter interface One, interface

1. Interfaces can be viewed as a special "abstract class".

2. Interfaces have better features than abstract classes

3. Can be multiple inheritance

4. Design and achieve complete separation

5. More natural use of polymorphism

Second, the interface convention

1. The interface represents a convention that is embodied in interface names and annotations (some interfaces have only names, and methods are implemented by annotations)

2. The interface is a capability: it is embodied in the method of the interface

3. Interface-oriented programming: interface-oriented conventions in programming without regard to implementation.

4. Interface-oriented programming: care about the capabilities of the implementation class, not the implementation details.

Third, interface syntax

public interface myinterface{

public void Foo () {

Other methods

}

Using interfaces: Writing interfaces, implementing interfaces, using interfaces

Four, interface characteristics

1. Interfaces may not be instantiated

2. The implementation class must implement all the methods of the interface

3. Implementation classes can implement multiple interfaces

4. Variables in the interface are constants

Using Java to implement object-oriented fourth chapter

Related Article

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.