Java interfaces can inherit multiple interfaces

Source: Internet
Author: User
An interface is a collection of constant values and method definitions. An interface is a special kind of abstract class. Java classes are single-inheritance. ClassB Extends Classajava interface can inherit more. Interface3 Extends Interface0, Interface1, interface ... The main reason for not allowing class multiple inheritance is if a inherits both B and C, and B and C have a D method at the same time, how does a determine the inheritance? But the interface does not exist such a problem, the interface is all abstract method inheritance who does not matter, so the interface can inherit multiple interfaces. Note: 1) If a class implements an excuse, it implements all the methods of the interface. 2) The name, return type, and parameters of the method must be exactly the same as the interface. If the return type of the method is not void, the method body must have at least one return statement. 3) Because the method of the interface is the public type by default, the implementation must be decorated with public (otherwise the default is the protected type, narrowing the use of the method).

Java interfaces can inherit multiple 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.