Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
class First //outer class
{
static int n=100;
static class Second //inner
{
static void display(int x)
{
System.out.println("Second class : "+n);
System.out.println("Parameter: "+x);
System.out.println(x+n);
}
}
}
class TestStaticNested
{
public static void main(String args[])
{
// First.Second fs=new First.Second();
// fs.display();
First.Second.display(500);
}
}
Program 2
interface Testouter
{
void display();
interface TestInner
{
void show();
}
}
class Test1 implements Testouter.TestInner
{
public void show()
{
System.out.println("This is show method of TestInner Test 1 Class");
}
}
class Test2 implements Testouter.TestInner
{
public void show()
{
System.out.println("This is show method of TestInner in Test 2 class");
}
}
class TestNestedInterface
{
public static void main(String args[])
{
Testouter.TestInner T1=new Test2();
T1.show();
}
}