Tuesday 29 April 2014

Abstract Class vs. Interfaces in Java

Hi All, This time I am back with a most controversial topic among java beginners. Yes, Its Abstract Class v/s Interface.
 Most of the developers prefer using Interfaces over abstract class for the following reasons.
  1. Any Class can be modified to implement the Interface, not necessarily the hierarchical type.
  2. Loosely coupled.
  3. Interfaces enable safe, powerful functionality enhancements.
  4. Overcome effect of absence of Multiple Inheritence
With these advantages it also bring one big difficulty that "Once an interface is
released and widely implemented, it is almost impossible to change".
so Interfaces need to be designed more carefully than an abstract class.