oop0
1 Page

oop0

Course Number: CS 100, Fall 2008

College/University: Cornell

Word Count: 129

Rating:

Document Preview

// 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)...

Unformatted Document Excerpt
Coursehero >> New York >> Cornell >> CS 100

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

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 Create a; // 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); } }
MOST POPULAR MATERIALS FROM CS
MOST POPULAR MATERIALS FROM Cornell