Showing posts with label java tricky program. Show all posts
Showing posts with label java tricky program. Show all posts

Tuesday, 4 August 2015

What is the output of following program?

  1. package com.javastepbystep;

  2. class A
  3. {
  4.  
  5.      static int method1(int i)
  6.     {
  7.          return method2(i *= 11);
  8.      }
  9.  
  10.       static int method2(int i)
  11.      {
  12.           return method3(i /= 11);
  13.       }
  14.  
  15.        static int method3(int i)
  16.       {
  17.            return method4(i -= 11);
  18.       }
  19.  
  20.       static int method4(int i)
  21.      {
  22.          return i += 11;
  23.      }
         
  24.      public static void main(String [] args)
  25.     {
  26.           System.out.println(method1(11));
  27.      }
  28.  
  29. }

Ans: 11