In: Computer Science
interface Sample
{
void show();
}
class A implements Sample
{
public void show()
{
System.out.println("A method");
}
}
class B extends A
{
public void show()
{
System.out.println("B method");
}
}
class C extends A
{
public void show()
{
System.out.println("C method");
}
}
class D extends A
{
public void show()
{
System.out.println("D method");
}
}
class E extends A
{
public void show()
{
System.out.println("E method");
}
}
class F extends A
{
public void show()
{
System.out.println("F method");
}
}
class DemoProgram
{
public static void main(String[] args)
{
Sample obj=new A();
obj.show(); //calls A show()
obj=new B();
obj.show(); //calls B show()
obj=new C();
obj.show();//calls C show()
obj=new D();
obj.show();//calls D show()
obj=new E();
obj.show();//calls D show()
obj=new F();
obj.show();//calls F show()
}
}
Output
A method
B method
C method
D method
E method
F method