What is difference between abstract class and interface?

What is difference between abstract class and interface?

The main differences  between abstract class and interface are given bellow.

                   abstract class

 1)abstract class can extend only one class or one abstract class at a  time

 2)A class can extend only one abstract class

 3)abstract class can have protected , public and public abstract methods

 4)abstract class can have static methods

 5)abstract class can have constructor.

 6)abstract class can have both abstract and concrete methods

 7)An abstract class can have method body (non-abstract methods).

 8)An abstract class can have instance variables.

 9)In abstract class keyword ‘abstract’ is mandatory to declare a method as an abstract

                                        interface

 1)nterface can extend any number of interfaces at a time

 2)A class can implement any number of interfaces

 3)Interface can have only public abstract methods i.e. by default

 4)Interface cannot have static methods.

 5)Interface cannot have constructor.

 6)interface can have only abstract methods

 7)Interface have only abstract methods.

8)An interface cannot have instance variables.

 9)In an interface keyword ‘abstract’ is optional to declare a method as an abstract


Read More →