Last active
November 19, 2015 10:30
-
-
Save rishi93/ca746ed2bdd37916f7e6 to your computer and use it in GitHub Desktop.
Example of Using Interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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