Sarah
Questions
What is the difference between an abstract class and an interface?
Q. What is the difference between an abstract class and an interface?
What the Interviewer Want to Know
They are looking for your understanding of how abstract classes allow partial implementation and shared behavior, while interfaces solely define a contract for implementing classes without any concrete state or implementation.
How to Answer
To answer this question effectively, start by defining both abstract classes and interfaces. Describe their key features, use cases, and how they differ in terms of inheritance and method implementation. Then, support your explanation with examples and scenarios where one is more suitable than the other.
Structure it like this:
  • Define abstract classes and interfaces.
  • Explain the purpose of each and their respective features.
  • Highlight the differences in inheritance and method implementation.
  • Provide examples or scenarios for their usage.
Example Answer
"An abstract class can provide both abstract methods (without an implementation) and concrete methods (with an implementation) along with fields, allowing you to share common behavior among a group of related classes, whereas an interface is meant to define a contract that classes must follow by providing only method signatures (and in modern languages, default methods) without any state, so you’d typically use an interface when you want to enforce consistency across unrelated classes without imposing a shared implementation."
Common Mistakes
  • Confusing class inheritance with interface implementation, assuming they serve the same purpose.
  • Neglecting to mention that an abstract class can contain fields and concrete methods, whereas an interface (traditionally) cannot hold state.
  • Overlooking that a class can implement multiple interfaces but can inherit from only one abstract class.
  • Failing to highlight that interfaces are used to define contracts, while abstract classes are used to share common code among related classes.

Unlimited Mock Interviews with Your Personal Career Advisor

Sarah Academy offers 1-on-1 mock interviews with Career Advisors who guide you through real questions and personalized feedback, helping you improve your answers and build lasting confidence.

Apply to Join Today
Interview Questions
Sarah Academy - UK Visa Sponsorship Jobs for Graduates & International Students