class Demo {
void show() {
System.out.println(\"i am in show method of super class\");
}
}
class Flavor1Demo {
// An anonymous class with Demo as base c
That depends on the context you are in.
The main(String[]) methods is a static methods.
To stay simple, that means it doesn't exist in an instance of Flavor1Demo, there is no this here. If you set d as non-static, it will only exist in an instance of Flavor1Demo so it can't be access from the main unless you build a instance first (new Flavor1Demo().d.show();
But a static variable will be link to the class an not an instance, Meaning you can access it from a static context. In you case, the main method.