Extending Interfaces

Interfaces can be extended as classes can be. Example :

interface base {
	void baseMethod();
}

interface derived extends base // extending interface
{
	void derivedMethod();
	//void baseMethod(); automatically comes here
}

class baseClass implements derived {
	public void baseMethod() {
		System.out.println("from first interface");
	}

	public void derivedMethod() {
		System.out.println("from second interface");
	}
}

public class InterfaceExtend {
	public static void main(String[] args) {
		baseClass b = new baseClass();
		b.baseMethod();
		b.derivedMethod();
	}
}