Interface Example 2

interface I1 {
}

interface int4 extends I1 {
	void disp1();
}
class A1 implements int4 {
	@Override
	public void disp1() {
		System.out.println("Disp in A1");
	}
}
class B1 implements int4 {
	@Override
	public void disp1() {
		System.out.println("Disp in B1");
	}
}
class C1 implements int4 {
	@Override
	public void disp1() {
		System.out.println("Disp in C1");
	}
}
public class InterfaceDemo2 {
	int4 iobj1, iobj2, iobj3;
	public InterfaceDemo2() {
		iobj1 = new A1();
		iobj2 = new B1();
		iobj3 = new C1();
	}
	void disp() {
		iobj1.disp1();
		iobj2.disp1();
		iobj3.disp1();
	}
	public static void main(String[] args) {
		new InstanceDemo2().disp();
	}
}

Download

Interface in Java

Interface Example - 1
Interface Example - 2


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code