The class Person is inside Lab1 class.In Lab1 a static variable pers of type Person is declared and used inside the main().Even though pers is of static type why is not possible to compile Lab1.If Person class is made static Lab1 compiles and returns the expected output.Since pers is inside main() it is of type static and it will refer to what ever exact object it will be pointed to.
Yes. The class you created inside the main() is a method local inner class. There is a special case with the method local inner classes.I recommend you to go through the static inner class, method local inner class and the anonymous inner and argument-defined anonymous inner class in deep. They are very important concepts of Java and are very helpful in certain cases.