What is the output of the program - draw a state diagram


What is the output of the following program?

Draw a state diagram that shows the state of the program just before the end of main. Include all local variables and the objects they refer to.
At the end of main, are p1 and p2 aliased? Why or why not?

public static void printPoint(Point p) { System.out.println("(" + p.x + ", " + p.y + ")");}public static Point findCenter(Rectangle box) { int x = box.x + box.width/2; int y = box.y + box.height/2; return new Point(x, y);}public static void main(String[] args) { Rectangle box1 = new Rectangle(2, 4, 7, 9); Point p1 = findCenter(box1); printPoint(p1); box1.grow(1, 1); Point p2 = findCenter(box1); printPoint(p2);}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: What is the output of the program - draw a state diagram
Reference No:- TGS02384390

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)