Sheeshy Sipgrark
New member
What will be the output of the following Java program?
A. 1 2
B. 1 1
C. 2 2
D. Compilation Error
Code:
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);
}
}
B. 1 1
C. 2 2
D. Compilation Error