What Will Be The Output Of The Following Java Programp Pre #247
What will be the output of the following Java program?</p> <pre><code class="language-java" line="1"> 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); } }</code></pre>
This multiple choice question (MCQ) is related to the book/course
gs gs128 Java.
It can also be found in
gs gs128 Java Classes Methods - Java Arrays Revisited & Keyword static - Quiz No.1.