πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 65 34

Explanation: 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.

Explanation by: Ravi Shankar
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
69
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Ravi Shankar
Publisher
πŸ“ˆ
81%
Success Rate