java and Implement

2022-12-29   ES  

Simple to say:
1.EXTENDS is the inheritance of the parent class. As long as the class is not a statement or that class is defined as abstract, it can be inherited.
2.java does not support multiple inheritance, but you can use interfaces to implement, so that implements are used,
3. Inheritance can only inherit one class, but Implements can implement multiple interfaces, just separate with a comma,
     , for example class A extends B implements C,D,E   

The term:
     Extends inheritance classes; iMplements implement interface.

The

 
     class and the interface are different: the class is procedural; and the interface is not allowed to implement it, only the predetermined method can be predetermined

     java also provides inheritance mechanism, but also provides another concept called interface. Since the inheritance mechanism of Java can only provide a single inheritance (that is, only one parent category can be inherited), Java’s interface is replaced by the multiple inheritance of C ++. Interface is an interface that specifies the two objects that want to communicate. What are the specifications of its communication.

     , from the perspective of Java programming language, Java’s interface indicates:

     Some functions or data members are jointly possessed by other objects that belong to different categories, and these functions and data members are defined in one interface, and then all different types of Java objects can be used together.
     Java Class can only inherit a parent class (using extends keywords), but you can have (or implementation) many interfaces (with Implements keywords).

What is the difference between 

Extends and Implements?
     For Class, Extends is used for (single) inheriting a class, and Implements is used to implement an interface. 

     interface is introduced to partially provides multiple inheritance functions. In the interface, you only need to declare the method header, and leave the method body to the implementation of the implementation. The instances of these implementation Class can be treated as an instance of Interface. The relationship between Extends (multiple inheritance) can also be declared between interface.

 Note: One interface can Extends multiple other interfaces. 

source

Random Posts

COUNTDOWLATCH understanding: The difference from Join

c# dynamic loading uninstall DLL

[java] -Base-thread

Simplify on ViewHolder in Baseadapter

Crontab plan task usage in detail