Given:
public class Main { static int myField = 2; public static void main(String[] args) { go(); //from w w w .java 2 s .c o m } static void go() { int myField = 3; zoomIn(); } static void zoomIn() { myField *= 5; zoomMore(myField); System.out.println(myField); } static void zoomMore(int myField) { myField *= 7; } }
What is the result?
B is correct.
In the Main class, there are three different variables named myField.
The go()
method's version and the zoomMore()
method's version are not used in the zoomIn()
method.
The zoomIn()
method multiplies the class variable * 5.
The result (10) is sent to zoomMore()
, but what happens in zoomMore()
stays in zoomMore()
.
The S.O.P. prints the value of zoomIn()
's myField.