ProAnswers.org

What are the differences between Interface and Abstract class?

1)An abstract class can provide complete, default code and/or just the details that have to be overridden.

1)An interface cannot provide any code at all,just the signature.

2)In case of abstract class, a class may extend only one abstract class.

2)A Class may implement several interfaces.

3)An abstract class can have non-abstract methods.

3)All methods of an Interface are abstract.

4)An abstract class can have instance variables.

4)An Interface cannot have instance variables.

5)An abstract class can have any visibility: public, private, protected.

5)An Interface visibility must be public (or) none(because by default public).

An abstract class can have concrete method, which is not allowed in an interface. Abstract class canhave private or protected methods and variables and only public methods and variables are allowed in interface. We can implement more than one interface , but we can extend only one abstract class. Interfaces provides loose coupling where as abstract class provides tight coupling.