For the following class What would be output by running this

For the following class

What would be output by running this program?

3.0 4.0

Solution

Answer: 1.0 4.0

Explanation :

we are creating Point p1 object by initializing the x and values with 1.0 and 2.0

Point p2 = new Point(3.0, 4.0);

we are creating Point p2 object by initializing the x and values with 3.0 and 4.0 p1.moveVertically(2.0);

we are addng value 2.0 with y. so y value in pi object is 2.0 now 2.0 value will get added so y = 2 + 2 =4. Now y vaue is 4 and x value remain same so it is 1

this statement will print 1.0 and 4.0

For the following class What would be output by running this program? 3.0 4.0 SolutionAnswer: 1.0 4.0 Explanation : we are creating Point p1 object by initializ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site