πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (D) i = 10, j = 20

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
280
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
94%
Success Rate