What Will Be The Output Of The Following Codep Pre Langcpp #334
What will be the output of the following code?</p> <pre><code class="language-cpp"> import java.awt.Point; class Testing { public static void main(String[] args) { Point p1,p2; p1=new Point(100,100); p2=p1; p1.x=200; p1.y=200; System.out.println(“Point 1: ” + p1.x + ”, “ + p1.y); System.out.println(“Point 2: ” + p2.x + ”, “ + p2.y); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 OOps Objects - OOPs MCQ: Object Reference - Quiz No.1.
What will be the output of the following code?
import java.awt.Point; class Testing { public static void main(String[] args) { Point p1,p2; p1=new Point(100,100); p2=p1; p1.x=200; p1.y=200; System.out.println(“Point 1: ” + p1.x + ”, “ + p1.y); System.out.println(“Point 2: ” + p2.x + ”, “ + p2.y); } }
Point 1: 100, 100 Point 2: 200, 200
Point 1: 200, 200 Point 2: 100, 100
Point 1: 100, 100 Point 2: 100, 100
Point 1: 200, 200 Point 2: 200, 200