Sunday, June 20, 2010

Difference Between abstract and interface?

• A class may implement any number of interfaces, but a class can extends only one abstract class or non-abstract class. • Every method in the interface should be public.
• Abstract class can have either abstract methods or concrete methods.
• The class which implements interface should implement all methods.
• Adding functionality is advantage of abstract class.
• If various implementations only share method signatures then it is better to use Interfaces, If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.

1 comment:

  1. hey,
    the major difference between abstract and interface is variable initialization in interface we cannot declare the variables expect public static final variables but coming to abstract class you declare and initialize the variables

    ReplyDelete