Given:
public class Main { int id; // w w w. ja v a 2s . c o m Main(int i) { id = i; } public static void main(String[] args) { Main h1 = new Main(1); Main h2 = h1.go(h1); System.out.println(h2.id); } Main go(Main h) { Main h3 = h; h3.id = 2; h1.id = 3; return h1; } }
What is the result?
D is correct.
Inside the go()
method, h1 is out of scope.