Doubts on Abstract Classes and Interface (java) [duplicate]

1

Before stating my doubt, it is valid to make it clear that in some way I understand the difference between the two.

I know that an abstract class can have implemented methods, attributes, constructors, and needs at least one abstract method. An interface can only contain the signature of the methods. However, my doubt goes a little deeper.

I do not know exactly when to use either ( example): Assuming my intent is to force my subclasses to implement certain methods ... an abstract class having these methods as abstract would no longer solve this problem? Then why would I use interfaces?).

That old example of the abstract class "Animal" and its subclasses: dog, cat, horse, etc. I've seen Animal being used as an example interface and abstract class, in this type of case would be the most appropriate and why?

    
asked by anonymous 08.10.2017 / 00:40

0 answers