64 Interface in Java

Code:

interface Vehicle
{
public abstract void windows();
public abstract void ac();
}

class Car  implements Vehicle
{
  public void windows()
{
System.out.println(" Car no of windows -6 ");
}

public void ac()
{
System.out.println(" Car Required AC ");
}
}

class Lorry implements Vehicle
{
  public void windows()
{
System.out.println(" Lorry no of windows -4 ");
}

public void ac()
{
System.out.println(" Lorry Not Required AC ");
}


}

abstract class Bus implements Vehicle
{
  public void windows()
{
System.out.println(" Bus no of windows -50 ");
}

public abstract void ac();
}

class Setwin extends Bus
{
public void ac()
{
System.out.println(" Setwin Not Required AC ");
}
}

class Volvo extends Bus
{
public void ac()
{
System.out.println(" Volvo Required AC ");
}
}

class Test
{
public static void main( String[] s )
{
System.out.println("\n\n Car: ");
Car car = new Car();
car.windows();
car.ac();

System.out.println("\n\n Lorry: ");
Lorry lorry = new Lorry();
lorry.windows();
lorry.ac();

System.out.println("\n\n Bus: ");
Setwin b1 = new Setwin();
b1.windows();

Volvo b2 = new Volvo();
b2.ac();
}
}


Output:



Previous
Next Post »