CS670K Homework Set 2 - Fall 1998

Due: Thursday, October 8

© Copyright University of New Haven 1998

class X
{
        static int i;
        int j;
        final static int k= 7;
        Y a= new Y();
        final static X c= new X();
}


class Y
{
        boolean i;
        static boolean j;
        final static boolean k= true;
}

class Z
{
        int i= 7;
        boolean j= false;

        public static void main(String arg[])
        {
                X p= new X();
                Y q= new Y();
                int j= 9;
                p.i= -5;  p.j= 3;
                q.i= true;  q.j= false;

// For each of the following statements, give the output or put ERROR
// as appropriate.  Omit the effect of erroneous statements at run-time,
// but PRESERVE the effect of preceding correctly executable statements.
  1. System.out.println( p.a.i= q.i );
  2. System.out.println( p.a.j= q.i );
  3. System.out.println( p.c.c.k );
  4. System.out.println( p.i= q.i );
  5. System.out.println( q.j );
  6. System.out.println( p.c.k= 4 );
  7. System.out.println( X.i= 6 );
  8. System.out.println( p.j= p.i );
  9. System.out.println( j += i );
  10. System.out.println( Z.j= q.i );
        }
}
Home Page