A

Admin • 828.03K Points
Coach

Q. Predict the output of following Java program.

Code:
class Test {
public static void swap(Integer i, Integer j) {
Integer temp = new Integer(i);
i = j;
j = temp;
}
public static void main(String[] args) {
Integer i = new Integer(10);
Integer j = new Integer(20);
swap(i, j);
System.out.println("i = " + i + ", j = " + j);
}
}
  • (A) i = 20, j = 20
  • (B) i = 10, j = 10
  • (C) i = 20, j = 10
  • (D) i = 10, j = 20
  • Correct Answer - Option(D)
  • Views: 14
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.