ICSE Class 10 Computer Applications Question 15 of 43

Conditional Constructs in Java — Question 15

Back to all questions
15
Question

Question 15

What will be the output of the following code?

int x=2,y=5,a=0;
a=x; 
x=y; 
y=a; 
System.out.println("x=" + x + " y=" + y);
Answer

Output is:
x=5 y=2

This code is swapping the values of x and y.