Tuesday, July 14, 2009

I'm having lots of trouble with my computer sci class. Can someone help me with this midterm problem?

What is the output from the following Java program fragment?





public static void main(String[] args)


{


int A = 10;


int B = 20;


Update(A, B);


System.out.println(A + " " + B);


}





public static void Update (int X, int Y)


{


X = X + Y;


Y = Y + X;


System.out.println(X + " " + Y);


}





A. None; there is a run-time error (before any output is produced)





B. 10 20


10 20





C. 10 20


30 50





D. 30 50


10 20





E 30 50


30 50

I'm having lots of trouble with my computer sci class. Can someone help me with this midterm problem?
Where are you stuck? Let us know what you think the answer should be and why.
Reply:D. 30 50


10 20





The variables are not passed by reference so they do not change in main.
Reply:D

flower girl dresses

No comments:

Post a Comment