Question d’entretien chez Nokia

“Explain the difference between an abstract class and an interface in Java. When would you use one over the other?”

Réponse à la question d'entretien

Utilisateur anonyme

19 août 2025

“An abstract class allows you to define some methods with implementation and others without. It’s useful when you want to provide a common base with shared code. An interface, on the other hand, is purely a contract—no implementation (at least before Java 8). I’d use an abstract class when I need shared behavior across subclasses, and an interface when I want to enforce a set of methods across unrelated classes.”