Abstract and Interface

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    #1

    Abstract and Interface

    Hi,

    I have little confusion on abstract class and interface. When should we use abstract class and interface.

    Do not reply the difference beween them. I need when to use abstract class and interface.

    Thanks & Regards,

    Srinivasan r.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    An interface is used when certain classes may have one or a few behaviours in common, but are fundamentally different. Example: A plant vase and a garbage truck are both Containers and might have a .add(Containabl e) function, but they are completely different ideas.

    An abstract class is used when several different classes have a lot of behavior in common, and in fact only differ slightly from each other. Example: There are several different kinds of Employees in a company, all of which have names, social security numbers, salaries, etc. and all get paid, but do different jobs.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by rsrinivasan
      Hi,

      I have little confusion on abstract class and interface. When should we use abstract class and interface.

      Do not reply the difference beween them. I need when to use abstract class and interface.

      Thanks & Regards,

      Srinivasan r.
      Read this thread.

      Comment

      Working...