When you are calling that increment function, you are passing a value 0 to it. It gets the value in that parameter variable i (not the static variable i), increases that and returns the incremented value of the parameter variable, means the static variable i is still unaffected.
Pinki Roy wrote:Since i is a static variable I think it should have displayed 1
1) int variables are never initialized to 1 automatically.
2) while automatically initializing a variable, only two things matter : a) if it is a class variable(method local variables are never initialized to default value, except arrays); b) data-type of that variable. It doesn't matter if the variable is static or not.
Besides this, why do you think first print statement should print 1?