Interface Class: Its some kind of contract between developer/Class implementation and real world/caller of class object that commits what kind of the provisions will be their that can be accessed from the class implementation and also implementation is bound to provide the implementation of this contract.
Abstract Class: Its also define some kind of contract that a implementing class signs and bound to implement all the abstract functions for which no implementation is provided in the abstract class. So outer world of implementing class have knowledge of all the provisions and availability of functionality that can be called directly from the object of implementer class.
Benefit of Interface over Abstract class: As from the definition of the abstract class question arises that when everything that an Abstract class enforce or provide then why concept of Interface still exists the most well known answer of this question comes while an implementing class comes to the situation when it has to implement more than one kind of contracts to the outer world which makes the requirement of multiple inheritance which is not possible in case of abstract class as an implementer class can not implement more than one abstract class but it can implement more than one Interface.
Benefit of Abstract class Over Interface: Both seems to be related to contract between object calling and class providing implementation of interface. Also in case of existence of interface class an additional benefit it also facilitate with the feature of multiple inheritance then why abstract class exists. Answer to this query comes from abstract class's another feature that says if some of the implementation that is known and predefine also is common and usable in derived classes too then in case of abstract class we can implement this functionality in abstract class itself that will be available with all the derived classes which is not possible with usage interfaces.
If there is any other difference/benefit for these then I request to viewers to add their comments that can be beneficial for other viewers too.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment