vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, October 17, 2012

Difference between Abstract Class and Interface


Abstract class
  • Abstract class has both Abstract methods and Non abstract methods.
  • Abstract class is a class that you cannot create instance on i.e. you cannot create new object for abstract class.
  • One or more class can derive the abstract class.
  • If we derive some methods in abstract class in derived class we may or may not implement those methods.
  • In abstract class we can use access modifiers like public, private.
  • Abstract methods have both method implementation and method declaration
  • Abstract class does not support multiple inheritances.
  • Abstract class we can define field and constant.
  • Abstract class we can use constructor or destructor.

Interface:

  • In interface we should implement all the methods in Derived class.
  • Interface we cannot use modifiers because by default those are public.
  • Interfaces have only method declaration it’s not method implementation. It has implanted only on derived class.
  • Interface support multiple inheritance.

0 comments:

Post a Comment