// Client program to explore reference semantics public class ReferenceExample { public static void main(String[] args) { // Example 1: Primitives int a = 4; int b = a; a = 7; System.out.println("a = " + a); System.out.println("b = " + b); System.out.println(); // Example 2: Objects (References) Point s = new Point(1, 2); Point t = s; s = new Point(3, 4); System.out.println("s = " + s); System.out.println("t = " + t); System.out.println(); t.setX(0); System.out.println("s = " + s); System.out.println("t = " + t); System.out.println(); } // pollev.com/cse143 // How many Point objects exist in this method? // What is the output of this method? public static void poll1() { Point p = new Point(1, 2); Point q = p; Point r = q; q = new Point(4, 5); r.setX(3); System.out.println("p = " + p); System.out.println("q = " + q); System.out.println("r = " + r); } }