employer cover photo
employer logo
employer logo

Tata Consultancy Services

Fait partie de Tata Group

Employeur impliqué

Question d’entretien chez Tata Consultancy Services

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

Réponse à la question d'entretien

Utilisateur anonyme

20 juin 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.