When do you give preference to abstract classs and interface?

1 answer

Answer

1061009

2026-04-19 00:15

+ Follow

Abstract class provides a way of "being a [something like me]", or inheritance

interface provides a set of functionality (contract) as "behaving".

Abstract class provides the single inheritance and perhaps some default implementation, while interface may be implemented by different classes that have nothing to do one and other except the common interface implementation.

The preference I would start with:

Ask yourself that an object should be "Is a something or behave like something". If your answer is "Is a", then abstract class is more likely your good choice. But if your answer is behave like, does not need to Is a, then the interface is the way to go.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.