Posts

Showing posts with the label Marker interface in java

Interfaces in java with example

Interface concept included in java to overcome the Diamond problem of multiple inheritance in java. In other words, Interface was introduced in java to define objects outside the world through methods. For example, buttons on the front of the television set. That are the interfaces between you and the electrical set. You press the power button to turn the television to on or off. An interface is a specification of method prototypes. Prototypes will be in the interface. All the methods of the interface are abstract. For the polymorphic interface inheritance, where the client wants to only deal with a type and does not care about the actual implementation use interfaces. If you need to change your design frequently, you should prefer using interface to abstract class. Through interfaces we can achieve multiple inheritance in java. Because there is a possibility of inheriting more than one interface into java class by using the keyword called implements. When we ...