Question d’entretien chez IBM

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

Réponses aux questions d'entretien

Utilisateur anonyme

8 juin 2010

an abstract class can have a method body whereas an interface cannot

Utilisateur anonyme

3 mai 2010

An abstract class is one whose main purpose is to define a common interface for its subclasses. An abstract class will defer some or all of its implementation to operations defined in subclasses; hence an abstract class cannot be instantiated Whereas an Interface you have to understand what do you mean by object type. An object's class defines how the object is implemented. The class defines the object's internal state and the implementation of its operations. In contrast, an object's type only refers to its interface—the set of requests to which it can respond