Contents    Page-10    Prev    Next    Page+10    Index   

Consider the Java code:


Integer i = 3;
foo(i);
System.out.println("i = " + i);

void foo (Integer j) {
  j++;
  System.out.println("j = " + j);
  return; }
Integer is immutable. What is printed?

  • A: Compile error
  • B: Runtime error
  • C: j = 3, i = 3
  • D: j = 4, i = 3
  • E: j = 4, i = 4

    Answer