4 Years
Discussion Span
Last Post by delta_frost

They have many similarities in how they are used, and a quick Google will find you lots of detailed discussion on the differences, but the shortest version is that abstract classes can contain far more than interfaces (eg actual method defininitions), but you can only extend one class at a time, while you can implement many interfaces.


An interface is more like a "template." It is the base for something. Like there could be an interface called Flyable. It would have methods for flying speed, how to fly etc. A duck would implement it. An abstract class would have some methods already built in like run. Every duck would run in the same way, right? Though it would also have some body-less methods. Note that an abstract class is a very basic duck and an interface is a template for a duck. The abstract class can then be overriden for advanced ducks.


abstract classes containing abstract and non-abstract methods.These are used to acheived polymorphism by overriding all the abstract method and essential non-abstract methods.Interfaces are the special class of the abstract classes.All the methods in Interface are must be abstract otherwise it will give COMPILE TIME ERROR.In case of Interfaces all the methods must be override.


An Interface is bound to contain abstract methods only whereas a Class CAN have concrete methods.
A Class CAN implement multiple Interfaces but CAN NOT extend multiple classes.
In an Interface all variables are static and final .But this need not be true in a Class.
The default access specifiers for the members of an Interface are public but it is not true for Classes.

An example where you will want to implement an Interface Runnable at the same time extending a Class Frame

class MyClass extends Frame implements Runnable{

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.