Java Program to show a simple interface example…


This java code is to show a simple interface demonstration.

interface Connection
{
void connect();
void disconnect();
}

class AccessDB implements Connection
{
public void connect()
{
System.out.println(“Connected with Access Database.”);
}

public void disconnect()
{
System.out.println(“Disconnected from Access Database.”);
}
}

class OracleDB implements Connection
{
public void connect()
{
System.out.println(“Connected with Oracle Database.”);
}

public void disconnect()
{
System.out.println(“Disconnected from Oracle Database.”);
}
}

class InterDemo
{
public static void main(String args [])
{
Connection ac;
ac=new AccessDB();
ac.connect();
ac.disconnect();

ac=new OracleDB();
ac.connect();
ac.disconnect();
}
}

Add Comment