employer cover photo
employer logo
employer logo

Tata Consultancy Services

Part of Tata Group

Engaged employer

Tata Consultancy Services interview question

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

Interview Answer

Anonymous

20 Jun 2025

I explained that both abstract classes and interfaces are used to achieve abstraction in Java, but there are key differences. An abstract class can have method implementations (concrete methods), constructors, and member variables, while an interface only contains abstract methods (until Java 8, when default and static methods were introduced). I also mentioned that a class can implement multiple interfaces, but it can only extend one abstract class. Additionally, I gave an example where an interface is preferable when multiple inheritance of type is required, and abstract class when sharing common code among related classes.