Actual concept differences:
Difference 1:
different modifier modifiers (interface), (extends)
Difference 2:
You can have multiple inheritance in object-oriented programming! However, multiple inheritance of interfaces is supported, and inheritance is not supported.
Whereas inheritance has a single root in Java, subclasses can inherit only one parent class
Difference 3:
Only global constants, and abstract methods, can be defined in an interface
In inheritance, you can define attribute methods, variables, constants, etc...
Difference 4:
When an interface is implemented by a class, the abstract method in the interface must be implemented in the class
And the inheritance wants to invoke that method and call that method without pressure.
The interface is: Description of the function inheritance is: What is a kind of what
Always Reporter: You can have more than one Father (interface), but only have a father (inherit)
Example:
If the dog's owner just wants the dog to climb the lower tree, but does not want it to inherit the tail can hang upside down in the tree, like the monkey can Feiyanzoubi, lest the master can't control it.
Then the owner of the dog must not want a dog inherited by a monkey.
Design patterns are more emphasis on interface-oriented. Monkeys have two interfaces, one is a tree climb, the other is a tail upside down. I just need my dog to climb the tree, but don't hang it upside down, so I'll just have to get my dog to climb the tree. At the same time will not bring like inherited monkeys to bring the tail upside down side effects. This is the benefit of the interface.
46353251
The differences between interfaces and inheritance in Java