What Will Be The Output Of The Following Java Codep Pre #516
What will be the output of the following Java code?</p> <pre><code class="language-java" line="1"> class A { int x; int y; void display() { System.out.print(x + " " + y); } } class Output { public static void main(String args[]) { A obj1 = new A(); A obj2 = new A(); obj1.x = 1; obj1.y = 2; obj2 = obj1.clone(); obj1.display(); obj2.display(); } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs128 Java. It can also be found in gs gs128 Exploring Java Lang Java IO - Java.lang - Rounding Functions - Quiz No.1.
What will be the output of the following Java code?
class A { int x; int y; void display() { System.out.print(x + " " + y); } } class Output { public static void main(String args[]) { A obj1 = new A(); A obj2 = new A(); obj1.x = 1; obj1.y = 2; obj2 = obj1.clone(); obj1.display(); obj2.display(); } }
1 2 0 0
1 2 1 2
0 0 0 0
System Dependent