Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given is the following code for class Point public class Point { private int m_x; private int m_y; public Point(){ this(0,0); } public Point(int x,

Given is the following code for class Point public class Point { private int m_x; private int m_y; public Point(){ this(0,0); } public Point(int x, int y){ setX(x); setY(y); } public void setX (int x) { m_x = x; } public void setY (int y) { m_y = y; } public int getX () { return m_x; } public int getY () { return m_y; } public String toString() { return "x loc = " + getX() + " y loc = " +getY() + " distance to orgin = " + String.format("%.2f",distanceToOrgin()); } public boolean equals (Point obj){ if (this.getX()!=obj.getX() || this.getY()!=obj.getY()) return false; return true; } public double distanceToOrgin(){ return Math.sqrt((getX()*getX())+(getY()*getY())); } } In a testing program are the following lines of code (numbered for easy reference)

1 Point pntA = new Point(); 2 System.out.println(pntA.toString()); 3 Point pntB = new Point(10, -25); 4 System.out.println(pntB.toString()); 5 Point pntC = pntB; 6 System.out.println(pntC.toString()); 7 Point pntD = new Point(5, 15); 8 System.out.println(pntD.toString()); 9 pntA = pntD; 10 System.out.println(pntD.toString()); 11 System.out.println(pntB.equals(pntD)); 12 System.out.println(pntC.equals(pntB));

What is output at line 2? ? What is output at line 4? ? What is output at line 6? ? What is output at line 8? ? What is output at line 10? ? What is output at line 11? ? What is output at line 12?

A. x loc = 15 y loc = 15 distance to orgin = 15.81

B. true C. x loc = 5 y loc = 15 distance to orgin = 15.81

D. x loc = 0 y loc = 0 distance to orgin = 0.00

E. false F. x loc = -25 y loc = 10 distance to orgin = 26.93 G. x loc = 10 y loc = -25 distance to orgin = 26.93

H. 1 I. 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions