// oop0.java DIS 2/14/2000 // see also oop1.java for more explanation //------------------------------------------------------------------------- // CLASS STUDENT //------------------------------------------------------------------------- class Student { int id; String name; } //------------------------------------------------------------------------- // CLASS OOP0 (contains main) //------------------------------------------------------------------------- public class oop0 { public static void main(String[] args) { // Declare a reference variable of class $Student$. Student a; // Create a new object and assign the reference to $a$ a = new Student(); System.out.println("(1) Reference $a$: " + a); System.out.println("(2) Reference w/o assignment: " + (new Student()) ); // Assign an integer to the $id$ field of the object referred to by $a$ a.id = 123456; // Assign a string to the $name$ field of the object referred to by $a$ a.name = "Ira"; // Check the fields of the object referred to by $a$ System.out.println("ID Field: " + a.id); System.out.println("ID name: " + a.name); } }