</>CodexBash
All articles
Programming

Interfaces vs abstract classes

When to use an interface and when to use an abstract class, explained in Java with notes for C#, Python, TypeScript and Kotlin: what each can contain, single versus multiple inheritance, default and static methods, the template method pattern, sealed types, designing around capabilities, and a clear decision guide with examples.

CodexBash, , 6 min read

"What is the difference between an interface and an abstract class?" is one of the most common questions in Java and object-oriented programming interviews, and a genuinely useful design decision in everyday code. Both describe something that other classes complete; neither can be instantiated on its own. But they model different relationships and have different capabilities, and modern Java features such as default methods have blurred the old textbook answer. This article explains both, what changed, and how to choose.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.