A

Admin • 828.03K Points
Coach

Q. Determine output:
public class Test{
int i = 34;
public static void main(String args[]){
Test t1 = new Test();
Test t2 = new Test();
t1.i = 65;
System.out.print(t1.i);
System.out.print(t2.i);
}
}

  • (A) 34 34
  • (B) 65 34
  • (C) 65 65
  • (D) 34 65
  • Correct Answer - Option(B)
  • Views: 9
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
Instance variable is unique for their object, that means each copy of memory for variable i will be available for each object. So, changing value of i from one object will not affect the value of i accessed by another object.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.