B
B
BonBon Slick2018-06-20 01:54:37
OOP
BonBon Slick, 2018-06-20 01:54:37

Why can an abstract class omit the implementation and declaration of the methods of the implemented interface?

Yes, this happens, after several years of coding I noticed such a feature, I had never used it before, and now I still have no idea how and where it can be used wisely. Previously did an abstract class or interfaces. I came across this in java public abstract class ArrayList implements List{and then I realized that you can skip methods from the interface, because IMHO there are a lot of them.
So, why and why so? How, where and when can and should it be applied?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Movchan, 2018-06-20
@BonBonSlick

The only difference between an interface and an abstract class is that an interface cannot have state (fields, variables). Thus, interfaces do not need to solve the problem of diamond-shaped inheritance.
There are no objective reasons for the rest of the differences - it's just syntactic sugar.

D
Dmitry Tallmange, 2018-06-20
@p00h

An abstract class does not contain descriptions of methods. In it, you can add your methods to the interface, and the description of the functionality will be handled by a real class that inherits the created abstract one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question