Difference Between Interface and Abstract Class

Following are the differences



• Abstract class may contain concrete methods but Interface contains methods that must be abstract.
• Abstract class may contain non-final and final variables But Interface contains variables that must be static and final.
• Abstract class can "extends" another class and "implements" multiple interfaces But Interface can "extends" another interface.
• Abstract class can be invoked if a main() exists but Interface is absolutely abstract
• Interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
• Members in an abstract class may contain non-public members but interface are public by default.
• Interface is used to "implements"; whereas abstract class is used to "extends".
• Interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.

++
Thanks and Regards
Meetu Choudhary


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: