How many Point objects are created by this program?
One — the object referenced by pt
How many temporary String objects are created by this program?
Two — one temporary String
object for each println()
The program changes the data inside a
Point object using that object's move() method:
import java.awt.*;
class PointEg4
{
public static void main ( String arg[] )
{
Point pt = new Point( 12, 45 ); // construct a Point
System.out.println( pt );
pt.move( -13, 49 ) ; // change the x and y in the Point
System.out.println( pt );
}
}
Can a constructor be used to change the data inside an object?