>

Saturday, December 15, 2012

Java Inner Class

What is out put?

// A program using in inner class and method over loading
class Outer{
   protected int a=6;
   public void methodOne(){
       a=a++;
       System.out.println("In methodOne outer class a "+a);
   }
       class Inner{
          
            public void methodOne(){
                int a=6;
                System.out.println("In method one value of a "+a);
            }
            public void methodTwo(){
                a=a--;
                System.out.println("In method two value of a "+a);
            }
       }
       public void methodTwo(){
           System.out.println("In outerclass method Two value of a "+a);
       }
      
}
public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Outer out=new Outer();
        Outer.Inner in=out.new Inner();
        out.methodOne();
        in.methodOne();
        in.methodTwo();
        out.methodTwo();
       
    }

}

No comments:

Post a Comment

Please post your comments. Your comments make us to write more programs for you.