Menu
Question Index
...

What will be the output of the following program?

public class MyBasicStaticMemberClass
{
    public static class MyStaticMemberExampleClass
    {
        public void printStatus()
        {
            System.out.println("Inside static member class");
        }
    }
    public static void main(String a[])
    {
        StaticMemberTestClass staticMemberTest = new StaticMemberTestClass();
        staticMemberTest.testMemberClass();
        System.out.println("Inside Main");
    }
    static
    {
        System.out.println("Static Block");
    }
}
class StaticMemberTestClass
{
        public void testMemberClass()
        {
            MyBasicStaticMemberClass.MyStaticMemberExampleClass myStaticMemberExample = new MyBasicStaticMemberClass.MyStaticMemberExampleClass();
            myStaticMemberExample.printStatus();
            System.out.println("Inside Class");
        }
}


Static Block
Inside static member class
Inside static member class
Inside Main
Inside static member class
Inside Class
Inside Class
Inside Main
Static Block
Inside static member class
Static Block
Inside static member class
Inside Main
Inside Class
Static Block
Inside static member class
Inside Class
Inside Main
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App