Define an interface Controllable containing two functions- start() and stop(). Define 2 classes Television and Game that implements Controllable interface with other details. Call the functions using variable Controllable. 


source file name:  LockDemo.java

// interfaceControllable have start (),stop () abstract methods

interface Controllable

{

public void start();

public void stop();

}

// implementation of Controllable interface

class Television implements Controllable

{

public void start()

{

System.out.println ("Television start()");

}

public void stop()

{

System.out.println("Television stop()");

}

}

// implementation of Controllable interface

class Game implements Controllable

{

public void start()

{

System.out.println("Game start()");

}

public void stop()

{

System.out.println("Game stop()");

}

}

class LockDemo

{

public static void main(String ad[])

{

Television t=new Television();

t.start();

t.stop();

Game g=new Game();

g.start();

g.stop();

}

}

output:


D:\JavaPrograms\InterfacePrgs>javac LockDemo.java

D:\JavaPrograms\InterfacePrgs>java LockDemo
Television start()
Television stop()
Game start()
Game stop()