← Back to OOP
OOP

Abstract Class vs Interface Interview Questions

What is the difference between an abstract class and an interface? — spoken sample answer for Indian interviews.

  • 5Questions with answers
  • 3Difficulty levels

Questions (5)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Beginner
Question

What is the difference between an abstract class and an interface?

Answer:

An interface is a capability contract. A class can implement many. An abstract class is a partial implementation with shared fields and maybe a constructor. You only get one class superclass in Java and C#. I use an interface when I want Payable or Comparable. I use an abstract class when several implementations share state and a template-method flow — validate, then execute, then audit. Java 8 default methods exist, but I keep them thin so I do not accidentally build a second inheritance tree. In Python I would mention ABC versus Protocol if they are in a Python round.

Question 2
Interview Intermediate
Question

When do you still choose an abstract class?

Answer:

When I need shared state or a template method with a protected helper. Interfaces should not hold instance fields. Capability without state is an interface. Two shared utilities are a helper, not a parent class.

Question 3
Interview Beginner
Question

Why can a class implement many interfaces but extend only one class?

Answer:

Multiple capabilities without multiple inheritance of state. A class can be Comparable and Serializable. One superclass. I design extra roles as interfaces. Default-method clashes are the remaining diamond.

Question 4
Interview Intermediate
Question

Would you add a new marker interface today?

Answer:

Serializable is the classic empty marker. Today I would often use an annotation. I would not invent a new empty interface unless a framework requires it.

Question 5
Interview Beginner
Question

How do you test code that depends on an interface?

Answer:

I inject a fake. FakePaymentGateway in tests. That is DIP plus interface. Abstract classes can use a test subclass, but interfaces are cleaner. Interviewers want tests, not only UML.

Practice with AI mock interviews

Run OOP mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required