Marcus Green mock exam...
What's the output of the following code??
class ValHold{
public int i = 10;
}
public class A{
public static void main(
String argv[]){
A o = new A();
o.amethod();
}
public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i=30;
another(v,i);
System.out.println(v.i);
}//End of amethod
public void another(ValHold v, int i){
i=0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ " "+i);
}//End of another
}
My answer is 20,0,20,but correct answer is 10,0,20
Can Somebody explain the code??
-------------------------------------
thanks for help , Liao