Skip to content

Instantly share code, notes, and snippets.

@rishi93
Last active November 19, 2015 10:30
Show Gist options
  • Save rishi93/ca746ed2bdd37916f7e6 to your computer and use it in GitHub Desktop.
Save rishi93/ca746ed2bdd37916f7e6 to your computer and use it in GitHub Desktop.
Example of Using Interface
import java.io.*;
interface StartStop
{
public abstract void start();
public abstract void stop();
}
class Car implements StartStop
{
@Override
public void start()
{
System.out.println("Car start");
}
@Override
public void stop()
{
System.out.println("Car stop");
}
}
class Bike implements StartStop
{
@Override
public void start()
{
System.out.println("Bike start");
}
@Override
public void stop()
{
System.out.println("Bike stop");
}
}
public class test2
{
public static void main(String args[])
{
StartStop c = new Car();
StartStop b = new Bike();
c.start();
b.start();
c.stop();
b.stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment