Header Ads

  • Breaking Now

    What is the use of interface?

    An interface is a collection of public abstract methods and read only i.e. public, static and final variables.
    The concept of interfaces in Java makes Multiple Inheritance a reality. Two or more non-related classes can implement the same interface. A class can implement multiple interfaces.Whenever there has to be an ancestry associated with classes along with some concrete behaviors then it is good idea to come up with abstract classes in such scenario but when implementation is more generic in nature and not dependent upon class relations or type hierarchy then such behaviors should be packaged inside an interface.The methods defined inside an interface can be implemented by non related classes.

    Post Top Ad

    Post Bottom Ad