Vidyalelo
Java Programming · Q109

Miscellaneous Java

Programming · Java Programming · question 109

Q109

What will be the output of the following Java program? class access static int x; void increment() x++; class static_use public static void main(String args[]) access obj1 = new access(); access obj2 = new access(); obj1.x = 0; obj1.increment(); obj2.increment(); System.out.println(obj1.x + " " + obj2.x);

A.
1 2
B.
1 1
C.
2 2
Answer
D.
Compilation Error

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board