Indeed, the variables need to be static, but I think you know that. This program will act in a potentially surprising way because although methodOne() assigns a value to the parameter "z", the member variable "z" remains unchanged. The parameter "z" and the member variable "z" are completely unrelated, and perhaps that's the root of the problems you're having.
There are several practices here that are bad habits, and perhaps I should just point them out. One is naming local variables or parameters the same as member variables. Although this isn't technically
wrong, it's always confusing and there's rarely an excuse for doing it. In this program I suspect that fact that you're reusing names is confusing
you. Another thing that's generally bad (although this one is more subtle) is writing methods which are useful only for their side effects. If you have a choice between writing
or
and then calling it as "c = method(1, 2)", the second choice is generally preferred. There are many reasons for this, but the two most important are that it makes it more obvious what the method does, and that it makes the method easier to
test in isolation. Methods whose explicit purpose is to set a variable are OK, by the way. That's why I said this point is subtle; it's a judgement call.