Monday, October 29, 2012

What is an interface in java

Basically, interface is a keyword in java. It is used for abstraction. Since multiple inheritance is not allowed in java, we are using interface to acheive the multiple inheritance.

All variables inside the interface is implicitly public and final constants and all the methods inside the interface is also public. We can call the variables just by calling the interface name.variable name.

An interface can extends as many of the interfaces whereas java class can extend only one class implements many.

We cannot define concrete methods in interfaces. Interfaces are pure Abstract class. If we implement the interface to a particular class, then that class must implement all the methods inside that interface. if we didn't implement all the methods then that class must be declared as a Abstract class.

No comments:

Post a Comment