Pergunta de entrevista da empresa ServiceNow

What is the difference between an interface and an abstract class in Java, and when would you use each?

Resposta da entrevista

Sigiloso

22 de jul. de 2025

I explained that an interface is a contract for what a class can do, without implementation, while an abstract class can have both abstract and concrete methods. I mentioned that I would use interfaces for multiple inheritance and abstract classes when I want to share common code among related classes.