Interface program

Write a program that illustrate the use of interface reference. Interface Luminious Object has two method lightOn() and lightOff(). There is one class Solid extended by 2 classes Cube and Cone. There is one class LuminiousCone extends Cone and implements Luminoius Interface. LumminuiousCube extends Cube and implements Luminious Interface. Create a object of LuminiousCone and LuminousCube and use the concept of interface reference to invoke the methods of interface.

interface Luminious
{
	void LightOn();
	void LightOff();
}
class Solid
{}
class Cone extends Solid
{}
class Cube extends Solid
{}
class LuminiousCone extends Cone implements Luminious
{
	public void LightOn()
	{
		System.out.println("Light on from Cone");
	}
	public void LightOff()
	{
		System.out.println("Light off from Cone");
	}
}

class LuminiousCube extends Cube implements Luminious
{
	public void LightOn()
	{
		System.out.println("Light on from Cube");
	}
	public void LightOff()
	{
		System.out.println("Light off from Cube");
	}
}
public class Practical16
{
	public static void main(String[] agrs)
	{
		LuminiousLCube = new LuminiousCube();
		LCube.LightOn();
		LCube.LightOff();

		LuminiousLCone = new LuminiousCone();
		LCone.LightOn();
		LCone.LightOff();

		}
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here