Java Program To Implement Nested Interface

An interface for example proclaimed inside another interface or class is known as nested interface. The nested interfaces are utilized to assemble related interfaces with the goal that they can be anything but difficult to keep up. The nested interface must be alluded by the external interface or class.

Java Program To Implement Nested Interface
interface MainInterface
{
void display();
interface NestedInterface
{
void displayNested();
}
}
class MainInt implements MainInterface
{
public void display()
{
System.out.println("Main Interface Implemented.");
}
}
class NestedInt implements MainInterface.NestedInterface
{
public void displayNested()
{
System.out.println("Nested Interface Implemented.");
}
}
class InterfaceTest
{
public static void main(String[] args) {
MainInterface mi = new MainInt();
MainInterface.NestedInterface ni = new NestedInt();
mi.display();
ni.displayNested();
}
}

OUTPUT:
Main Interface Implemented.
Nested Interface Implemented.

tags : java, java programs , java tutorial, java tutorialspoint, tutorialspoint ,learn java , java code , code hour ,interface ,nested , c ,programs of c , c++ , programs of c++

Post a Comment

Previous Post Next Post