Computer Applications

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);

Java Conditional Stmts

4 Likes

Answer

Output is:
x=5 y=2

This code is swapping the values of x and y.

Answered By

1 Like


Related Questions