## More about Objects and Classes

The relational operations on primitive data are ==, >=, <=, >, <, and !=. They compare two data values, when those values' type has an ordering. For example, integers are ordered by size or magnitude. The result of a relational operation is a boolean value: either True or False. The relational operators on objects like Strings are different, and they are expressed as methods. Pay special attention to the equality method, equals().

### 5. Instantiating the Point Objects

**Answer:**

Say that the program has just been loaded and is __just about__ to start running.

How many reference variables are there? 3

How many objects are there? Zero

# Instantiating the `Point `

Objects

`Point `

Objects`a`

, `b`

, and `c`

do not refer
to any objects. To emphasize this, a slash has been put through the box for each variable.
import java.awt.*; class PointEg1 { public static void main ( String arg[] ) { Point a, b, c; // reference variables a = new Point(); // create a Point at (0, 0); // save the reference in "a" b = new Point( 12, 45 ); // create a Point at (12, 45); // save the reference in "b" c = new Point( b ); // create a Point containing data equivalent // to the data referenced by "b" } } |

The program:

- Declares three reference variables
`a`

,`b`

, and`c`

, which can hold references to objects of type`Point`

. - Instantiates a
`Point`

object with x=0 and y=0.

(The documentation tells us that a constructor without parameters initializes x and y to zero.) - Saves the reference to the object in the variable
`a`

. - Instantiates a
`Point`

object with x=12 and y=45. - Saves the reference to the object in the variable
`b`

. - Instantiates a third
`Point`

object that is similar to the second. - Saves the reference in the variable
`c`

.

Once each `Point`

object is instantiated, it is the same as any other (except for the particular values in the data). It does not matter which constructor was used to instantiate it.

**Question 5:**

What are the values of `x`

and `y`

in the third point?