// Practice1.java
// contains classes P and Practice1
//
// Preparation for output problems on a quiz
// or exam.
//
// Before you run this program, write down on paper
// what you think the complete output will be.
// Then run the program to see if you were right.


class P  {

   private static int objectCount = 0;

   private int objectNumber;

   public P()
   {
      objectCount++;
      objectNumber = objectCount;
      System.out.println("*** constructor P(): object#="
                         + objectNumber + ", class="
                         + getClass().getName());
   }  // constructor P()

   public void p()
   {
      System.out.println("--- P: p()");
   }  // method p()

   public String toString()
   {
       return (getClass().getName() + ":object#" + objectNumber);
   }  // method toString()
}  // class P


public class Practice1  {
   public static void main(String[] args)
   {
      P[] array = new P[5];

      for ( int i=0; i<5; i++ )
          array[i] = new P();

      for ( int i=0; i<5; i++ )
      {
          System.out.println("Begin testing array[" + i + "]:  "
                             + array[i].toString());
          array[i].p();
          System.out.println("End testing array[" + i + "]:  "
                             + array[i]);  // automatic call to
                                           // array[i].toString()
      }  // for i
   }  // method main
}  // class Practice1