Interface is collection of abstract method.
Using the keyword interface,you can fully abstract a class interface from its implementation.
example of interface:
interface Callback
{
void callback(int p);
}
class Client implements Callback
{
public void callback(int p)
{
System.out.println("This is Client Interface " + p);
}
}
class Customer implements Callback
{
public void callback(int p)
{
System.out.println("This is Customer Interface " + p);
}
}
class Interface
{
public static void main(String args[])
{
Callback c = new Client();
c.callback(50);
Customer c1 = new Customer();
c = c1;
c.callback(100);
}
}
Using the keyword interface,you can fully abstract a class interface from its implementation.
example of interface:
interface Callback
{
void callback(int p);
}
class Client implements Callback
{
public void callback(int p)
{
System.out.println("This is Client Interface " + p);
}
}
class Customer implements Callback
{
public void callback(int p)
{
System.out.println("This is Customer Interface " + p);
}
}
class Interface
{
public static void main(String args[])
{
Callback c = new Client();
c.callback(50);
Customer c1 = new Customer();
c = c1;
c.callback(100);
}
}
No comments :
Post a Comment