public class TestStudent { public static void main(String[] args) { Student s1 = new Student(); //instantiate using default constructor Student s2 = new Student("Roberta", "Thomas"); Student s3; //not yet instantiated - no problem (it's just like declaring 'int x;' ) s2.setHwTotal(268); s2.setFinalExamScore(92); s2.setStudentId(33422933); s3 = new Student(s2); //instantiate (used copy constructor) //output s1 using toString System.out.println("Outputting the \'s1\' object's state using toString"); System.out.println(s1); //Test toString //Note that they have the same state System.out.println("Object \'s2\':"); System.out.println(s2); System.out.println("Object \'s3\':"); System.out.println(s3); //Even though s2 and s3 have identical state, they are still // DIFFERENT objects, so this will be false. System.out.println("Comparing the references using == :"); if ( s3 == s2) System.out.println("Same"); else System.out.println("Different"); System.out.println(); //Compare the STATE of the objects using 'equals' method //In this case, because the state of the two objects is identical, //the equals method returns true System.out.println("Comparing the state using equals method:"); if ( s3.equals(s2) ) System.out.println("Same"); else System.out.println("Different"); System.out.println(); } //end main } //end class TestStudent