The situation when the interface is better than the abstract class

Please tell me where the interface is better than the abstract class in Java

+5
source share
8 answers

I think you misunderstood the real meaning of an interface and an abstract class.

An interface is a programming structure in which you define your functions / services that you want to open to public or other modules. The type of contract in which you promise that you provide some functions or services, but hide the implementation, so that you can change the implementation without affecting your contract.

, , . - , . - .

. . , , ( ), .

+6
  • , .
  • -, . , (, ).
+5

, - .

, :

+2

. , .

+2

Java ; , , . , MouseListener ActionListener , .

+1

, , , .

0

WebServices JMock, , . , , , , API.

0

When you need to implement in any class, because an interface can be implemented in any class or interface, but an abstract class cannot do this, for example. in Applet, the Applet class is always distributed in our Applet application, in which case we cannot extend the abstract class.

0
source

All Articles