In the following example, the line: AbstractTest.MyInner minn = new AbstractTest().MyInner() is giving error. It expects ; at the end of this line, but I am trying to instantiate it anonymously and get the value of minn.num. Can anyone explain me how it can be fixed?
But besides this, I see that your classes are written as if you expect variables to behave polymorphically -- they do not. You should never redefine a variable in a subclass like this. If the variable needs to have a different value in a subclass, then assign a different value in the constructor of the subclass (or in an anonymous class, in an initialization block). But never try to "override" a variable -- you'll just get weird, hard to understand results.