An Interface in java programming language is exact copy of a class. It consist of abstract methods and static constants. Interface is a method which is used to achieve abstraction. It contains abstract methods not the method body. It is used to achieve abstraction and multiple inheritance in java. It represents the IS-A relationship. Reasons why to use Inheritance in java? 1) It is used to achieve abstraction. 2) By interface, we can support the functionality of multiple inheritance. 3) It can be used to achieve loose coupling.( loose coupling in java means that the classes are independent of each other. The only knowledge one class has about the other class is what the other class has exposed through its interface in loose coupling.). Declaration of an Interface in Java Interface in java is declared using the keyword that is interface keyword. It provides that total abstraction, that means all methods in the interface are declared with empty body and all the fields are public, s
Programming World and Facts.
This blog is related to the programming languages, FAQ's and Facts about the programming languages..