S
S
Sergey Nizhny Novgorod2017-06-07 01:48:42
Java
Sergey Nizhny Novgorod, 2017-06-07 01:48:42

Does it make sense to use an abstract class in Java?

Hello everyone
. Such a question: is it necessary to use abstract classes in Java, if interfaces give almost the same thing, only with additional goodies?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-06-07
@Terras

This is a classic interview question - what is the difference between an abstract class and an interface. The correct answer is that an abstract class allows you to inherit behavior , or implementation. Everything else is a consequence.
A great example is implementations of the standard List interface. They are most often inherited from the abstract AbsList class, which implements some basic methods.
That is, when implementations of an interface have the same behavior, it is worth thinking about an abstract ancestor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question