In Java, what is the difference between a abstract class and an interface?
While you can’t instantiate either one, this is where the similarity ends, and it is probably this reason why people ask it. An abstract class is marked abstract because you want a class that contains methods that can only be used by children classes that extend it (and supposedly add some remaining ingredients to make the class valid). This allows a class to contain code, but can’t be instantiated (for whatever reason you need). An interface, on the other hand, is really an API contract. It contains no code, just the list of methods that any class claiming to implement it needs to create. These two things have such a different semantic meaning that I was surprised the first time I heard it. But it has been asked in every one of my screening interviews. As a design note, if you are building a library, make your users implement an interface instead of extending one of your classes, since Java doesn’t do multiple inheritance, it is mean to use up a user’s one chance at extension.