An interface is a concept independent of the language. However,some languages like Java have interface as a language keyword which implement this general concept of interface. An interface is a contract which an object promises to honor."How" the contract is honored is up to the object but what it assures is the "what" part of the contract. We can also say that an interface is the facade which the object puts up for the outside world to interrogate and interact.
An interface is a set of methods or that's behavior and which the clients interact with the given class implementing the interface through intteractive class .
Syntax for declaring the Interface :
<interface name> { return type method name1(Par1);
return type method name2(Par2);
Final constant value N;
}
Example :
interface readable{
void read();
}
class software implements readable{
public void read()
{System.out.println("Mindstick");}
public static void main(String args[]){
software obj = new software();
obj.read();
}
}
output : Mindstick.
Happy Coding :)
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Interface :
An interface is a concept independent of the language. However,some languages like Java have interface as a language keyword which implement this general concept of interface. An interface is a contract which an object promises to honor."How" the contract is honored is up to the object but what it assures is the "what" part of the contract. We can also say that an interface is the facade which the object puts up for the outside world to interrogate and interact.
An interface is a set of methods or that's behavior and which the clients interact with the given class implementing the interface through intteractive class .
Syntax for declaring the Interface :
<interface name> {return type method name1(Par1); return type method name2(Par2); Final constant value N; }
Example :
interface readable{ void read(); } class software implements readable{ public void read() {System.out.println("Mindstick");} public static void main(String args[]){ software obj = new software(); obj.read(); } }output : Mindstick.
Happy Coding :)