6. What is difference between anonymous inner class and general class?
7. What is difference between normal inner class and static nested class?

       

Normal Inner Class Static Nested Class
  1. Inner class object always associated with outer class object ie without existing outer class object    there is no chance of existing inner class object.
  1. Nested class object never associated with
       outer class object , ie  without existing outer class object inner class object can exist
  1. Inside normal inner class we cant declare static members.
  1. Inside static nested class can
         declare static members
  1. We cant place main method in normal inner class and hence innocation of inner class directly from   command prompt is not possible.
  1. We can place main method in static nested class and    hence  innocation of nested class directly from command prompt is possible
  1. From normal inner class we can access both static and non static members of outer class.
  1. From static nested class we can access only static member of outer class

8.What is static nested calss?why the term nested instead of inner in static nested class?

      Some times we can declare inner class with static modifier such type of inner  class are called static

       nested classes.the term nested instead of static because without existing outer class object inner

       class object can exist. 

       Example

      Class outer{

      Static class Nested{

            Public static void main(String[] args){

                  System.out.println(“nested class main()”);

            }

      }

      Public static void main(String[] args){

            System.out.println(“outer class main()”);

      }


9. Inside inner class is it possible to declare main()?

          No it is not possible to declare main () inside inner class but in static nested class it is possible for 

        Example refer above code