Domanda di colloquio di ServiceNow

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

Risposta di colloquio

Anonimo

22 lug 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.