Java Interface (top)

Source: Internet
Author: User

1. The methods in the interface are abstract methods. In general, abstract classes are not necessarily abstract methods. Abstract methods must be in an abstract class, as well as non-abstract methods. Inheriting the subclass of the abstract parent class, if there is still an abstract method, then this subclass is also an abstract class. That is, as long as there are abstract methods in the class, the class must be an abstract class, but abstract classes are not necessarily abstract methods.

2. Inheritance of interfaces:

Because the methods in the interface are abstract class methods. Subclasses want to be able to instantiate a method that must all rewrite the interface, so you must use a more, different

3. The difference between a method in an interface and a method definition inside an abstract class

abstract void Show () in the inner method of the abstraction class; is the default and method in the interface: public static final int num = 3;public static void show ();

4. A class that implements an interface cannot be instantiated as long as there is an abstract method.

5. If the member does not write a fixed modifier, it is added by default.

6.

7.

8. The benefits of multiple inheritance (can recognize multiple fathers at the same time, the benefits are many, you can get multiple methods at the same time) (disadvantage: There is the same method, will increase the uncertainty of the call)

9. The benefits of interfaces ( interfaces can be implemented in multiple implementations, which is the result of a multi-inheritance mechanism being improved in Java. A class can implement multiple interfaces )

10. The uncertainty of multiple inheritance is due to the fact that the methods of the parent class are subject. But interface implementations do not have this problem, because the body of the method is defined in the class that implements the interface

11. If the method of the abstract class is non-void

This is called the function of the Declaration, with the method body called function content or function implementation. As to how the method is implemented, it is the realization of the class.

Myth: The function in the interface must be explicit type, parameter.

12. Myth: (This will cause the call of uncertainty, is wrong)

Java Interface (top)

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.