20-CS-122-001 Computer Science II Spring 2012
A Simple Class

Virtual functions, classes, inheritance, lists, queues, stacks, applications

   
//  A Simple Class

class Simple {
   int number;
   
   public Simple() {}
   public Simple(int n) { number = n; }
   public void display() { System.out.println("The number is "+number); }
   public void multiply (int n) { number *= n; }
}

public class e {
   public static void main (String args[]) {
      Simple a = new Simple(100);
      a.display();
      a.multiply(3);
      a.display();
   }
}

// Sample Output:
//   The number is 100
//   The number is 300
//   The number is 50